android - 软键盘打开时 DialogFragment 不会上升

标签 android layout view keyboard

我在应用程序的其他地方有对话框,工作正常(键盘不隐藏 View ),但在我写的这个特定的新对话框中,当键盘打开时,它不会向上移动 View 。我不明白为什么..

我的对话框布局:

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

在我的 list 中设置。

最佳答案

找到解决方案:

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

在 onCreateDialog 回调中

关于android - 软键盘打开时 DialogFragment 不会上升,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38950747/

相关文章:

android - 包android.support.design.widget不存在

android - 我的 TVertScrollBox 不想在 Android 上滚动

mysql - PostgreSQL - 创建 View 时需要帮助

mysql - 将 View 从 oracle 转换为 mysql

android - Crashlytics 安卓 NDK : missing all symbols in crash reports

Android: fragment 无法获得 Activity

java - 这种观点不受约束

java - BoxLayout 粘在顶部

css - 表格中的标签/输入固定流体布局

iphone - 应用程序并不总是在主视图中启动