2014-07-26 32 views
0

好了,所以我有一個抽屜佈局的friendslist功能,像這樣:如何停止鍵盤在Drawerlayout中扭曲ListView?

enter image description hereenter image description here

正如你所看到的,我需要的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> 
+0

是否可以將'ListViews'高度設置爲'wrap_content'而不是'match_parent'? –

+0

發佈您的佈局xml代碼 –

+0

沒有區別我害怕@XaverKapeller。 – Chucky

回答

0

沒準你正在使用的RelativeLayout作爲你的主視圖組要求。將它切換到LinearLayout,並給ListView設置0的高度和1的權重。給底部佈局設置wrapcontent的高度並且不設置重量。

不要忘記給你的LinearLayouts(垂直或水平)的方向。