BottomSheetDialog 覆盖整页 - Android SDK
BottomSheetDialog covers full page - Android SDK
我目前正在 Android 中制作 BottomSheetDialog 并向其添加布局。但是这个对话框覆盖了整个页面。但这里有一些图片:
https://prnt.sc/vlkq18(显示打开对话框后应该可见的activity)
https://prnt.sc/vlkq73(显示打开对话框时的样子)
所以基本上问题是对话框覆盖了整个页面。这是代码:
createListButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MyListActivity.this, R.style.BottomSheetDialogTheme);
View view = getLayoutInflater().inflate(R.layout.dialog_create_list,null);
bottomSheetDialog.setContentView(view);
bottomSheetDialog.show();
}
});
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@drawable/bottom_sheet_background"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:text="Hello" />
</androidx.constraintlayout.widget.ConstraintLayout>
出现这个问题的原因是什么?
谢谢
好的,我自己找到了答案。将此添加到 BottomSheetDialog 的样式中。
<item name="android:background">@android:color/transparent</item>
谢谢:)
我目前正在 Android 中制作 BottomSheetDialog 并向其添加布局。但是这个对话框覆盖了整个页面。但这里有一些图片:
https://prnt.sc/vlkq18(显示打开对话框后应该可见的activity) https://prnt.sc/vlkq73(显示打开对话框时的样子)
所以基本上问题是对话框覆盖了整个页面。这是代码:
createListButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MyListActivity.this, R.style.BottomSheetDialogTheme);
View view = getLayoutInflater().inflate(R.layout.dialog_create_list,null);
bottomSheetDialog.setContentView(view);
bottomSheetDialog.show();
}
});
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@drawable/bottom_sheet_background"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:text="Hello" />
</androidx.constraintlayout.widget.ConstraintLayout>
出现这个问题的原因是什么?
谢谢
好的,我自己找到了答案。将此添加到 BottomSheetDialog 的样式中。
<item name="android:background">@android:color/transparent</item>
谢谢:)