I have an activity with a bunch of EditText fields on it, and the windowSoftInputMode is set to adjustPan, this mostly does what I want, however for the editText at the bottom of the layout, it doesn't pan enough. It'll pan to show the top line of a multiline edit text, but as soon as you hit enter, the cursor moves down a line and is now hidden under the keyboard.

Is there anyway I can make it pan further so that the top of the editText is all the way at the top of the window.

Using adjustResize definitely won't do what I want, pan is the right thing, just need it to pan further.

有帮助吗?

解决方案

Same thing was happen with me.

What I did to resolve is, I just put all the controls in ScrolllView.

And set android:windowSoftInputMode adjustResize. So whenever keyboard is open it will scroll the screen to adjust the view and Edittext always show on screen.

Hope this idea works for you.

Thanks

其他提示

Put your EditText inside the ScrollView and then give property adjustResize, instead of adjustPan, it will automatically adjust your screen and its components.

i have edittext at bottom of the screen when I touched on it open softkeyboard but it hide the edittext, so make the changes in layout(use relative layout )and it works for me without using adjustPan.Here is my XML.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gen_mainlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:id="@+id/headerlinearLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/navigation_bar" >

            <Button
                android:id="@+id/chatterBack"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="20dp"
                android:background="@drawable/navigation_cancel_button"
                android:textColor="#FFFFFF" >
            </Button>

            <TextView
                android:id="@+id/ittletextView"
                style="@style/titleText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="Title" >
            </TextView>

            <Button
                android:id="@+id/blockhide"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="20dp"
                android:background="@drawable/navigation_cancel_button"
                android:padding="5dp"
                android:text="Block/Hide"
                android:textColor="#FFFFFF" >
            </Button>
        </RelativeLayout>

        <LinearLayout
            android:id="@+id/middlelinearLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/headerlinearLayout"
            android:orientation="vertical" >

        </LinearLayout>


        <LinearLayout
            android:id="@+id/footerlinearLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@drawable/commnet_post_bg"
            android:gravity="center"
            android:paddingLeft="5dp"
            android:paddingRight="5dp" >


            <EditText
                android:id="@+id/sendeditText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dp"
                android:layout_weight="1"
                android:background="@drawable/comment_post_text_box"
                android:imeOptions="actionSend|flagNoEnterAction"
                android:inputType="text"
                android:paddingLeft="10dp"
                android:paddingRight="5dp"
                android:singleLine="true" >
            </EditText>

            <Button
                android:id="@+id/sendButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/send_button"
                android:text="Send"
                android:textColor="#FFFFFF" >
            </Button>
        </LinearLayout>
    </RelativeLayout>

</LinearLayout>

You need to add this line into your activity for adjusting screen.

        <activity android:name=".TodoEdit"
        android:windowSoftInputMode="adjustResize">
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top