Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BottomSheetDialog not showing?

I'm trying to implement the new BottomSheetDialog, but when I call .show() it display the background shadows but not my layout.

This is my code

<?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>

And then:

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

How can I fix this issue?

like image 351
Eric Avatar asked Apr 19 '16 15:04

Eric


1 Answers

I got this problem, the reason for me is

  1. the dialog XML name is same with other module XML file name, so try rename it to another one

  2. check the layout file, maybe it has some error, keep the simplest layout test it.

like image 122
wudizhuo Avatar answered Sep 28 '22 10:09

wudizhuo