简体   繁体   中英

Hidden EditText when soft keyboard appears

I have this typical issue when soft keyboard appears for user to enter input and covers the EditText where text should appear.

I tried many different "fixes" and solution without success. I guess there is certain combination in my layout that causes this issue.

Right now in AndroidManifest.xml I have this line

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

The layout with the EditText is as follows witht he EditText at bottom

<?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>

Other things worth commenting is that I have this EditText with visibility gone until certain points in the app where the user is prompted to enter comments. Then I change visibility to visible and when user taps on the text the soft keyboard appears. It appears hiding everything behind it. No Resize or Pan operation is done.

The view that holds the EditText is infalted code-behind and inserted inside another view inside a PopupWindow.

So is like MainActivity > PopupWindow > ViewFlipper > EditText

I wonder if either PopupWindow or ViewFlipper add some poison to soft keyboard management.

Thanks in advance

Try this:

android:windowSoftInputMode="adjustResize|adjustPan|stateHidden"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM