2016-10-11 41 views
2

我在我的应用程序中有一个对话框片段,里面有一个autocompletetextview,但下拉列表而不是对齐软键盘的顶部,放在后面,不能访问一些这几项。在对话框中的软键盘背后的Autocompletetextview下拉列表

这里的布局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:padding="10dp" 
    android:orientation="horizontal" 
    android:windowSoftInputMode="adjustPan|adjustResize"> 

    <android.widget.AutoCompleteTextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:id="@+id/customDialogAtocompleteTextview" 
     android:layout_weight=".7" 
     android:layout_gravity="top" /> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight=".3"> 
     <Button 
      android:id="@+id/customDialogBtOk" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Aceptar"/> 
     <Button 
      android:id="@+id/customDialogBtSearch" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Buscar"/> 
     <Button 
      android:id="@+id/customDialogBtMore" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Mas"/> 
    </LinearLayout> 

</LinearLayout> 

所以我怎样才能使其与键盘一致?

回答

6

理论说,android:windowSoftInputMode="adjustPan|adjustResize"建议立即进行删除做到这一点,但由于某种原因,它不这样做,所以你必须以编程方式做同样的:

getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

Aaaaaand,奇迹发生了

相关问题