2013-04-29 112 views
2

在一個片段我用此佈局Android鍵盤重疊的EditText

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/header_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gravity="center" > 

<LinearLayout 
    android:id="@+id/layoutButtonAdd" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:orientation="vertical" > 

    <ImageView style="@style/line" /> 

    <Button 
     android:id="@+id/buttonAdd" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:text="@string/addSrButton" 
     android:visibility="gone" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/layoutList" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@id/layoutButtonAdd" 
    android:layout_alignParentTop="true" 

    android:orientation="vertical" > 


    <LinearLayout 
     android:id="@+id/progressContainer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:orientation="vertical" 
     android:visibility="gone" > 

     <ProgressBar 
      style="?android:attr/progressBarStyleLarge" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingTop="4dip" 
      android:singleLine="true" 
      android:text="" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/listContainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:paddingBottom="1dip" 
     android:paddingLeft="9dip" 
     android:paddingRight="4dip" 
     android:paddingTop="1dip" > 

     <ListView 
      android:id="@android:id/list" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:descendantFocusability="beforeDescendants" 
      android:drawSelectorOnTop="false" 
      android:visibility="gone" /> 

     <TextView 
      android:id="@+id/internalEmpty" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 
    </LinearLayout> 

</LinearLayout> 

向該android:id="@android:id/list"我動態地添加所需視圖(編輯文本,例如)。

問題是,如果我第一次點擊EditText,它會佔用焦點,窗口會正確調整平移。但是如果我點擊已經擁有焦點的editText,鍵盤會出現,但是它會重疊所需的EditText字段(即調整搖攝不能正常工作)。 在我的清單文件android:windowSoftInputMode="adjustPan"中設置。 ​​

我已閱讀關於包裝與ScrollView包裝佈局的技巧,但我已經有垂直滾動(LinearLayout)的元素。

任何想法?

回答

2

嘗試使用機器人:windowSoftInputMode =「adjustResize」

+0

這是不適合我「因爲我在這個EDITTEXT底部的一些看法溶液(按鈕佈局的底部至少) – 2013-04-29 11:19:45

+0

哦,你可以清潔香港此鏈接http://www.vogella.com/blog/2010/10/25/android-windowsoftinputmode/ – Rupali 2013-04-29 12:20:03