【发布时间】:2016-04-19 15:28:05
【问题描述】:
我正在尝试实现新的 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();
我该如何解决这个问题?
【问题讨论】:
-
你能在哪里解决这个问题?
-
在其上显示BottomSheetDialog时不要使用constraintLayout作为根布局...
-
我们可以检查几个步骤: 1. 使用静态方法 newInstance 2. 尝试将 linearLayoutCompat 作为根布局 3. 尝试彩色背景以获得想法 4. 尝试根布局的 match_parent height 5. 制作确保没有调用关闭或取消 6. 检查可见性 7. 重新启动:PC 和设备
标签: android material-design bottom-sheet