BottomSheetDialog 没有显示?

Eri*_*ric 8 android material-design bottom-sheet

我正在尝试实现新的BottomSheetDialog,但是当我调用.show()它时显示背景阴影而不是我的布局。

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="4dp"
            android:paddingBottom="4dp"
            android:paddingStart="8dp"
            android:paddingEnd="8dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Notes"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:textColor="@android:color/black"/>

            <Switch
                android:id="@+id/notes"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentEnd="true"/>

        </RelativeLayout>

    </RelativeLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

进而:

    mSettingsDialog = new BottomSheetDialog(this);
    View v = getLayoutInflater().inflate(R.layout.reader_settings,  null);
    mSettingsDialog.setContentView(v);
    mSettingsDialog.show();
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

wud*_*huo 2

我遇到这个问题,对我来说原因是

  1. 对话框 XML 名称与其他模块 XML 文件名相同,因此请尝试将其重命名为另一个名称

  2. 检查布局文件,可能有错误,保留最简单的布局测试一下。