制作一个布局,包含editText和按钮,使其位于键盘上方。

3
我有一个布局,底部包含一个EditText和一个按钮。在此之上是一个ListView。当键盘弹出时,我希望EditText和按钮保持可见状态。但是尽管设置了windowSoftInputMode="adjustResize",这并没有发生。以下是我的布局:
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/recents_header_bg"
    android:padding="2dp" >

    <TextView
        android:id="@+id/tv_msg_header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Name"
        android:textColor="@color/white1"
        android:textSize="15sp" />

    <Button
        android:id="@+id/bt_msg_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="@drawable/bt_call_log"
        android:text="Cancel"
        android:textColor="@color/white1" />
</RelativeLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="center"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/lv_msg_thread_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:cacheColorHint="#00000000"
        android:divider="@color/recents_list_seperator"
        android:dividerHeight="1dp"
        android:duplicateParentState="true"
        android:fadingEdge="none"
        android:fastScrollEnabled="true" >
    </ListView>

    <TextView
        android:id="@+id/tv_msg_error"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:visibility="gone" />
</FrameLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey05"
    android:orientation="vertical"
    android:padding="1dp" >

    <EditText
        android:id="@+id/et_msg_entry"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:gravity="top"
        android:hint="Type your message here" />

    <Button
        android:id="@+id/bt_msg_send"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:background="@drawable/bt_call_log"
        android:text="Send"
        android:textColor="@color/white1" />
</LinearLayout>

此外,在我的活动清单选项中还给出了:

<activity
        android:name=".ui.MessageActivity"
        android:screenOrientation="portrait" 
        android:windowSoftInputMode="stateHidden|adjustResize"
        android:exported="false"/>

有没有办法完成这个操作?就像默认的短信应用一样。
1个回答

1

您的LinearLayout方向应该是horizontal,而不是vertical


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接