[英]How to stop keyboard from distorting ListView in Drawerlayout?
好的,所以我在抽屜式布局中有一個好友列表功能,如下所示:
如您所見,我需要某種方法來保持LinearLayout的edittext和按鈕將其上方的列表視圖向上推,而不是出現在其頂部。 我該如何實現?
編輯:我的代碼,按要求
<RelativeLayout
android:id="@+id/relative_layout"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start" >
<ListView
android:id="@+id/left_drawer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter friend name" />
<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendMessage"
android:text="Add" />
</LinearLayout>
</RelativeLayout>
您可能會將RelativeLayout用作主視圖組。 將其切換到LinearLayout,並將ListView的高度設置為0並將權重設置為1。將底部布局的高度設置為wrapcontent且不設置權重。
不要忘記給您的LinearLayouts定向(垂直或水平)。
您可以簡單地將活動的windowSoftInputMode標志切換為“ adjustPan”。 查看官方文檔http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft了解更多信息。
<activity
...
android:windowSoftInputMode="adjustResize">
</activity>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.