Transparent bottom sheet layout in Android -
i trying make transparent bottom sheet layout, allow me see contents of view below it. bottom sheet working expected, when set background either @null
or @android:color/transparent
, layout's view white, opposed transparent. layout follows:
app_bar_main.xml:
<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinatorlayout" android:background="@android:color/transparent" android:fitssystemwindows="true" tools:context=".core.activities.mainactivity"> <!-- stuff here --> <linearlayout android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:background="@null" android:orientation="vertical" app:layout_behavior="@string/bottom_sheet_behavior"> </linearlayout> </android.support.design.widget.coordinatorlayout>
the linear layout id bottom_sheet
holds, well, bottom sheet. sheet defined follows:
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:background="@null" android:layout_height="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@null" android:orientation="vertical"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/bottom_sheet_placeholder_layout" android:layout_weight="0.6" android:layout_width="match_parent" android:background="@null" android:layout_height="50dp" android:orientation="horizontal"> </linearlayout> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/bottom_sheet_layout" android:layout_margin="0dp" android:layout_weight="0.4" android:layout_width="match_parent" android:background="@color/my_background" android:layout_height="wrap_content" android:orientation="vertical"> <progressbar android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/my_progress_bar" /> <textview android:layout_margintop="5dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="large text" android:textcolor="@color/my_text" android:id="@+id/txt_my_info" android:layout_gravity="center_horizontal" android:visibility="gone" android:textsize="48px" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="medium text" android:id="@+id/txt_my_address" android:textcolor="@color/my_secondary_text" android:visibility="gone" android:layout_gravity="center_horizontal" /> </linearlayout> </linearlayout> <android.support.design.widget.floatingactionbutton android:id="@+id/btn_edit_tree_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:layout_margintop="-62dp" android:elevation="100dp" android:src="@drawable/ic_create_black_24dp" app:layout_anchor="@id/bottom_sheet_layout" app:layout_anchorgravity="top|end|right" app:usecompatpadding="true"/> </android.support.design.widget.coordinatorlayout>
private void setupdialogbackground() { getdialog().setonshowlistener(new dialoginterface.onshowlistener() { @override public void onshow(dialoginterface dialog) { bottomsheetdialog d = (bottomsheetdialog) dialog; framelayout bottomsheet = (framelayout) d.findviewbyid(r.id.design_bottom_sheet); if (bottomsheet == null) return; bottomsheetbehavior = bottomsheetbehavior.from(bottomsheet); bottomsheet.setbackground(null); } }); }
Comments
Post a Comment