2016-08-15 57 views
0

我在應用程序的其他地方有對話框,工作得很好(keyboad沒有隱藏視圖),但是在我寫的這個特定的新對話框中並沒有移動當鍵盤打開時查看。我想不通爲什麼..當軟鍵盤打開時DialogFragment不上去

我的對話框的佈局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/MyLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_margin="15dp" 
    android:background="@drawable/dialog_background" 
    android:clickable="true" 
    android:orientation="vertical" 
    custom:maxHeight="@dimen/dialog_max_height" 
    custom:maxWidth="@dimen/dialog_max_width" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:layout_marginBottom="10dp" 
     android:gravity="center" 
     android:text="something" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <EditText 
      android:id="@+id/SomeEditText" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:minHeight="100dp" 
      android:layout_margin="15dp" 
      android:background="#ffffff" 
      android:gravity="right|top" 
      android:inputType="textMultiLine" 
      android:singleLine="false" 
      android:textColor="@color/edit_text_text_color" 
      android:textSize="16dp" /> 

    </LinearLayout> 

    <Button 
     android:id="@+id/SomeButton" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/dialog_button_height" 
     android:layout_margin="15dp" 
     android:text="text" /> 

</LinearLayout> 

我有我的清單

android:windowSoftInputMode="adjustPan" > 

集。

+0

顯示你的清單文件。 –

+0

我有'android:windowSoftInputMode =「adjustPan」'。但它在應用程序的其他對話框中工作得很好,所以我認爲它沒有任何關係。我也嘗試過adjustResize,但沒有幫助 – BVtp

+0

在清單 –

回答

1

找到了解決辦法:

我把:getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

在onCreateDialog回調

相關問題