软键盘打开时,DialogFragment不会启动

时间:2016-08-15 07:13:19

标签: android layout view keyboard

我在应用程序中其他地方的对话框工作得很好(键盘没有隐藏视图),但在这个特殊的新对话框中,我写道当键盘输入时它不会移动视图上。我无法弄明白为什么......

我的对话框布局:

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

在我的清单中设置。

2 个答案:

答案 0 :(得分:1)

找到解决方案:

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

onCreateDialog回调中的

答案 1 :(得分:0)

我也面临相同的问题,并通过保留getDialog()。getWindow()。setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)来解决 里面oncreateview