简体   繁体   中英

Make bottom sheet have a shadow at the top android studio

I am having a bottom sheet and i would like the top to have a shadow because the back fragment is white and the bottom sheet is also white and is confusing

Below is the code of the bottom sheet


<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:behavior_hideable="true"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

    <RelativeLayout
        android:id="@+id/bottomsheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Bottom Sheet Text"
            android:textSize="30sp"/>
    </RelativeLayout>
</androidx.core.widget.NestedScrollView>

add

 android:elevation="15dp"
 android:outlineProvider="bounds"

to your bottomsheet viewgroup(RelativeLayout)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM