英文:
What is the best way to create top shadow targeting API level 21?
问题
我有一个底部弹出窗口,我想实现以下图片效果:
[![点击查看图片描述][1]][1]
目前它的外观是平的,像这样:
[![点击查看图片描述][2]][2]
那么,我该如何在底部弹出窗口上添加一个顶部阴影并使其可滑动?在底部弹出窗口中,我有一个线性布局用作背景,例如:
<!-- 这是应用了 BottomSheetBehavior 的背景内容 -->
<LinearLayout
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:behavior_peekHeight="356dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<!-- 这是带有标题和图标的背景头部 -->
<RelativeLayout
android:layout_width="match_parent"
android:background="@drawable/front_backdrop_top"
android:layout_height="90dp">
</RelativeLayout>
<!-- 最后,这是背景内容的主体部分 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="8dp"
app:elevation="8dp"
android:background="@drawable/fron_backdrop_main"
android:paddingStart="28dp">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fs_rv_search"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</LinearLayout>
[1]: https://i.stack.imgur.com/PZ2hj.jpg
[2]: https://i.stack.imgur.com/nqz5v.jpg
英文:
I have a bottom sheet and I want to achieve the following image
right now it looks flat like:
So how could I add a top shadow on a bottom sheet, that slides. In bottom sheet I have a linear layout for the backdrop for example something like:
<!--This is the backdrop's content with a BottomSheetBehaviour applied to it-->
<LinearLayout
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:behavior_peekHeight="356dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<!--This is the backdrop's header with a title and icon-->
<RelativeLayout
android:layout_width="match_parent"
android:background="@drawable/front_backdrop_top"
android:layout_height="90dp">
</RelativeLayout>
<!--And finally this is the body of the backdrop's content-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="8dp"
app:elevation = "8dp"
android:background="@drawable/fron_backdrop_main"
android:paddingStart="28dp">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fs_rv_search"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</LinearLayout>
专注分享java语言的经验与见解,让所有开发者获益!
评论