2014-05-02 53 views
0

我有一个活动,包含listview和底部有edittext和底部对齐 类似于whatsapp默认活动 当我点击底部的编辑文本软键盘推底部和编辑文本了,但它合乎理列表视图做相同,所以钮下的列表视图disapear和文本视图Android的活动像什么应用程序默认活动

这里的底部是我的XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context="com.test.testsms.app.SMSList"> 

    <ListView 
     android:id="@+id/contactList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:dividerHeight="0px" 
     android:divider="#00000000" 
     > 
    </ListView> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <Button 
      android:text="@string/app_name" 
      android:id="@+id/Button" 
      android:layout_alignParentRight="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </Button> 

     <EditText 

      android:id="@+id/EditText" 
      android:layout_width="fill_parent" 
      android:layout_toLeftOf="@id/Button" 
      android:layout_height="wrap_content"> 
     </EditText> 

</LinearLayout> 


</LinearLayout> 

回答

2

如果你想推的EditText用键盘,你必须设置RelativeLayout而不是主Rin earLayout。因此包含edittext和button的LinearLayout将位于活动的底部。当你点击编辑文本时,键盘会被推上去。

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent"> 

...<ListView>  

<EditText 
android:layout_height="wrap_content" 
android:layout_width="match_parent" 
android:layout_alignParentBottom="true" 
android:selectAllOnFocus="true" 
android:textStyle="normal" 
> 
</EditText> 

</RelativeLayout> 
+0

edittext已经推动与botton,但问题与列表视图它没有推高 –

+1

哦!疑难杂症。非常抱歉!你解决了这个问题吗? – kimkevin

+0

还没有尝试过几件事 –