我在应用程序的其他地方有对话框,工作正常(键盘不隐藏 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/