我在底部片段中有一个编辑文本.当焦点出现在编辑文本上时,布局就会上升.我试过了
android:windowSoftInputMode="adjustNothing"
Run Code Online (Sandbox Code Playgroud)
它的工作是父活动,但不是对话框片段.
这是我的底层课程:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
初始状态
当键盘出现时
我希望布局始终保持在底部,键盘应位于布局上方.
检查布局
<?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" />
Run Code Online (Sandbox Code Playgroud)
如何在Android中折叠toolbarlayout中设置标题和子标题,如whatsapp个人资料视图.
我附上了相同的样本屏幕截图.
