简体   繁体   中英

BottomSheetDialog covers full page - Android SDK

I am currently making a BottomSheetDialog in Android and added a Layout to it. But this dialog covers the full page. But here are some pictures:

https://prnt.sc/vlkq18 (It shows the activity that should be visible after opening the Dialog) https://prnt.sc/vlkq73 (It shows how it looks like when opening the Dialog)

So basically the problem is that the Dialog covers the full page. Here is the code:

        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>

What is the reason for this problem?

Thank you

Ok i found the answer myself. Add this to the style of your BottomSheetDialog.

<item name="android:background">@android:color/transparent</item>

Thank you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM