2016-10-11 2 views
2

J'ai un fragment de dialogue dans mon application avec un autocompletetextview, mais la liste déroulante au lieu d'être alignée sur le dessus du clavier logiciel est placée derrière, ne donnant pas accès à certains des éléments suivants: Les objets.Menu déroulant de saisie automatique derrière un clavier virtuel dans un fragment de dialogue

Voici la mise en page:

<?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> 

Alors comment puis-je faire pour l'aligner sur le clavier?

Répondre

6

théorie dit que android:windowSoftInputMode="adjustPan|adjustResize" Shoul faire cela, mais pour une raison quelconque, il ne le font pas, donc vous devez faire la même chose programatically:

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

Aaaaaand la magie se produit