软键盘出现时隐藏EditText

时间:2015-08-07 08:03:29

标签: android android-layout keyboard android-edittext

当出现软键盘供用户输入输入并覆盖EditText时,我会遇到这个典型问题。

我尝试过很多不同的修复方法"和解决方案没有成功。我想我的布局中有某种组合会导致这个问题。

现在在AndroidManifest.xml中我有这一行

<activity       
    android:screenOrientation="landscape"
    android:windowSoftInputMode="adjustPan">

使用EditText的布局如下,底部为EditText

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:fillViewport="true"
    android:scrollbars = "vertical"
    android:windowSoftInputMode="adjustPan|adjustResize">

<LinearLayout
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/cargoRoot"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth" >  

    <LinearLayout
        android:layout_height="wrap_content" android:layout_width="600dp"
        android:orientation="vertical" >

        <TextView style="@style/smalltext" />

        <TextView
              android:id="@+id/arrivalEta"
              android:layout_height="wrap_content" android:layout_width="wrap_content" />

        <TextView
            android:text="@string/cargoComments"
            style="@style/smalltext" />

        <ScrollView android:id="@+id/scrollEditCargoComments"
                    android:layout_width="fill_parent"      android:layout_height="142dp"
                    android:scrollbars="vertical">
            <EditText
            android:id="@+id/editCargoComments"             
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textSize="@dimen/text_normal"
            android:minLines="5"
            android:imeOptions="actionDone"
            android:imeActionLabel="@string/send"
            android:inputType="textNoSuggestions"  />
            </ScrollView>
        </LinearLayout> 
    </RelativeLayout>
</LinearLayout>

其他值得评论的事情是,我有这个EditText的可见性,直到应用程序中提示用户输入注释的某些点。然后我将可见性更改为可见,当用户点击文本时,软键盘出现。 它似乎隐藏了它背后的一切。没有调整大小或平移操作。

保存EditText的视图是隐藏代码隐藏的,并插入到PopupWindow内的另一个视图中。

就像MainActivity&gt; PopupWindow&gt; ViewFlipper&gt;的EditText

我想知道PopupWindow或ViewFlipper是否会给软键盘管理添加一些毒药。

提前致谢

1 个答案:

答案 0 :(得分:-1)

试试这个:

机器人:windowSoftInputMode = “adjustResize | adjustPan | stateHidden”

相关问题