使键盘不向上推视图

Make keyboard not push up view

图值千言:

所以我希望我的第一个 LinearLayout 像操作栏一样工作,而不是被键盘向上推。我尝试 android:isScrollContainer="false" 并在清单中添加 "adjustPan""adjustResize",但我没有得到我想要的。

这是我的 XML:

<!-- layout 1 -->
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/caller_info"
    android:layout_alignParentTop="true"
    android:isScrollContainer="false"
    android:layout_marginTop="@dimen/last_message_margin">
        <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/txt_caller_name"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_marginLeft="@dimen/side_margins"
            android:layout_marginStart="@dimen/side_margins"/>
</LinearLayout>


<!-- layout 2 -->
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/dialog"
    android:layout_below="@+id/caller_info"
    android:layout_above="@+id/write_msg_layout">
</LinearLayout>


<!-- layout 3 with edit text -->
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:id="@+id/write_msg_layout">

    <EditText
        android:layout_marginBottom="30dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="@dimen/side_margins"
        android:layout_marginStart="@dimen/side_margins"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/edit_text"
        android:hint="Write Msg"
        android:textColorHint="@color/grey_as_clouds"
        android:background="@color/white_as_stone"
        android:imeOptions="actionSend"
        android:singleLine="true" />
</LinearLayout>

终于明白了。您必须用 ScrollView 围绕您的视图并使用 adjustResize.

并删除android:isScrollContainer="false".