问题描述
我见过类似的问题,但是没有一个答案能解决我的问题。 我有一个简单的BottomSheetDialogFragment,其中带有editText和一个按钮,当我选择editText时,键盘将覆盖按钮。
我从这个问题中测试了几个答案,没有任何运气: Bottom Sheet Fragment comes up with keyboard
我的BottomSheetDialogFragment:
public class AddUserBottomSheetFragment extends BottomSheetDialogFragment {
public static AddUserBottomSheetFragment newInstance() {
return new AddUserBottomSheetFragment();
}
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
return inflater.inflate(R.layout.bottom_sheet_add_user,container);
}
}
片段对话框的布局:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/bottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/contacts_bottom_sheet_background"
app:behavior_hideable="true"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
app:behavior_peekHeight="500dp" >
<EditText
android:id="@+id/insert_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<Button
android:id="@+id/add_user_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/contacts_add"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/insert_user" />
</androidx.constraintlayout.widget.ConstraintLayout>
我正在使用这种方法在我的活动中将其显示为简单的linearLayout作为参数:
public void showBottomSheet(View view) {
AddUserBottomSheetFragment addDialogFragment = AddUserBottomSheetFragment.newInstance();
addDialogFragment.show(getSupportFragmentManager(),"bottomSheetContainer");
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)