android - BottomSheetDialog 没有显示?

标签 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>

然后:

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

我该如何解决这个问题?

最佳答案

我遇到了这个问题,我的原因是

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

  2. 查看布局文件,可能有错误,保持最简单的布局测试。

关于android - BottomSheetDialog 没有显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36722879/

相关文章:

java - 从 JSON 对象获取二进制数据

Angular2 Material 工具提示 - 未添加类

android - 约束布局内的回收器 View 问题

android - 禁止拖动具有可滚动子项的 BottomSheetDialogFragment

android - 新的 Google Now 和 Google+ 卡片界面

jquery - 想要在我的 Droid 上使用 jQuery

java - 为什么我们不需要在Android中实例化LayoutInflater?

安卓 : Creating a full screen translucent overlay with z-order

android - 如何将 FAB 塑造成圆角按钮(药丸形状),类似于联系人应用程序的联系人详细信息屏幕?

dart - Flutter 底板圆角半径