2012-05-15 73 views
0
<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/sortByName" /> 

<ListView 
    android:id="@+id/listViewContacts" 
    android:layout_width="fill_parent" 
    android:layout_weight="0.9" 
    android:layout_height="0dp" > 
</ListView> 

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.1" 
     android:orientation="horizontal" > 


<EditText 
    android:id="@+id/editTxtSearch" 
    android:layout_width="225sp" 
    android:layout_height="wrap_content" 
    android:hint="Search Contacts..." 
    android:focusable="true"> 

    <requestFocus /> 
</EditText> 

<Button 
    android:id="@+id/btnSearch" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Search" 
    android:layout_gravity="right" /> 
</LinearLayout> 

键盘在屏幕上会自动出现在活动开始和编辑文本没有出现正常即没有文字显示在编辑文本编辑文本的高度收缩。的EditText异常出现在屏幕上

回答

0

您可以使用下面的代码行,以确保键盘,只有当用户点击进入弹出一个EditText

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

而且

您需要添加

android:windowSoftInputMode="adjustResize" 

添加到AndroidManifest.xml文件中的活动标签。