java - 如何在弹出软键盘时使聚焦的 EditText 可见?

标签 java android uiview android-manifest android-softkeyboard

我正在尝试制作布局内内容密集的应用程序。但是我想要的功能是在弹出软键盘时继续在屏幕的上半部分显示我的焦点 EditText ...

到目前为止,我的研究表明我必须使用...

   <activity android:windowSoftInputMode="adjustUnspecified" android:name=".main">
        <intent-filter>
            <action android:name="com.last.project.main" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

有人告诉我 Manifest.xml 的 (this) android:windowSoftInputMode="adjustUnspecified"行可以解决我的问题,但它似乎不起作用。 (有人告诉我意味着......从这个链接我读到 http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft )

只需要知道为什么它不起作用...是否有任何其他原因可能会影响我的 list XML 忽略我写的内容?

如果需要任何其他代码,请告诉我

谢谢,

克里奥

我的布局 XML 是...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_height="wrap_content" 
    android:id="@+id/linearLayout1" 
    android:layout_width="match_parent">
    <ImageView android:src="@drawable/header" 
        android:layout_height="wrap_content" 
        android:id="@+id/imageView1" 
        android:layout_width="match_parent" >
    </ImageView>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" 
    android:id="@+id/linearLayout2" 
    android:layout_width="match_parent" 
    android:baselineAligned="false" 
    android:layout_gravity="fill">
        <Button android:layout_height="wrap_content" 
            android:text="English" android:id="@+id/button1" 
            android:onClick="languageSelectionButtonFrom" 
            android:layout_width="wrap_content" 
            android:layout_weight="2">
        </Button>
        <ImageButton android:layout_height="wrap_content" 
            android:src="@drawable/arrow" 
            android:id="@+id/imageButton1" 
            android:layout_width="wrap_content">
        </ImageButton>
        <Button android:text="English" 
            android:onClick="languageSelectionButtonTo" 
            android:id="@+id/button3" 
            android:layout_gravity="right" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_weight="2">
        </Button>
</LinearLayout>
<TableLayout android:id="@+id/tableLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent">
        <EditText android:hint="Text to translate..."  
            android:layout_width="wrap_content" 
            android:id="@+id/editText1" 
            android:layout_height="wrap_content">
        </EditText>
        <Button android:text="Translate" 
            android:id="@+id/button4" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:onClick="translationButtonClickHandler" >
        </Button>
        <TextView android:text="Translation :" 
            android:textSize="15sp" 
            android:id="@+id/textView1" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content">
        </TextView>
        <EditText android:text="" 
            android:layout_width="wrap_content" 
            android:id="@+id/editText2" 
            android:scrollbars="vertical" 
            android:layout_weight="4" 
            android:gravity="top"  
            android:layout_height="match_parent">
        </EditText>
     </TableLayout>
</LinearLayout>

最佳答案

问题已经解决 谢谢各位脑洞大开的人...

答案是...我们必须将所有布局内容放在 ScrollView 中才能使它正常工作!

所以,就我而言

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
....(All other content omitted for whole file reference same xml text inside question)
</LinearLayout>
</ScrollView>

关于java - 如何在弹出软键盘时使聚焦的 EditText 可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6098346/

相关文章:

java - Groovy 类中 @Rule(JUnit) 声明和赋值的逻辑是什么

java - Eclipse OnErrorListener 无法解析为类型

java - tomee 中的此代码数据源配置在没有 Eclipse 的情况下运行正常,但是当我在 Eclipse 中运行时,它给出错误

java - AppEngine 连接的 Android 项目中的注释失败

Android (Kotlin) 无法访问 TableRow 元素的子元素

ios - 设置纵向和横向的 UIView 位置

java - Android 应用程序因 imageview 崩溃

android - 葫芦-android |请断言单选按钮自定义步骤帮助

ios - 在 iOS 中运行长任务时加载 "overlay"

ios - UIScrollView drawRect 中的自定义 UIView 从未调用过