【发布时间】:2016-09-02 09:23:11
【问题描述】:
我在底部工作表片段中有一个编辑文本。当焦点出现在编辑文本上时,布局会上升。我试过了
android:windowSoftInputMode="adjustNothing"
它适用于父 Activity,但不适用于对话框片段。
这是我的底部工作表类:
public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.content_dialog_bottom_sheet, container, false);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
return v;
}
}
初始状态
当键盘出现时
我希望布局始终保持在底部,键盘应位于布局上方。
检查布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@android:color/holo_blue_light"
android:padding="@dimen/activity_vertical_margin"
app:behavior_hideable="true"
app:behavior_peekHeight="60dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<EditText
android:id="@+id/edt"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@android:color/white"
android:padding="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="250dp"
android:layout_below="@+id/edt" />
【问题讨论】:
-
您是否以编程方式尝试过?发布屏幕截图以获得更多想法。
-
你能给我你的底片片段的代码吗?我想和你在上面实现的键盘上方的底片一样。@DKV
标签: android bottom-sheet