我一直在尝试设置 Bottomsheet
Google 在他们的应用程序(例如 GOOGLE NEWS 等)中使用的方式,
This is how Google's
Bottomsheet
looks like the following
Where my
Bottomsheet
looks like the following
马上你会注意到两件事,
我的 bottomsheet
代码如下(为了简单起见,我删除了控件)
MyBottomSheet.xml
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet"
android:elevation="10dp"
android:minHeight="300dp"
app:behavior_peekHeight="120dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<>
android:layout_width="match_parent"
android:layout_height="match_parent">
<>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="30dp">
<>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
我在我的代码中调用它如下
View view = LayoutInflater.Inflate(Resource.Layout.MyBottomSheet, null);
Dialog dialog = new BottomSheetDialog(this);
dialog.SetContentView(view);
如何获得圆角并确保底部导航不透明?
câu trả lời hay nhất
要获得 Google 的模态 BottomSheet 设计,请按以下方式实现它。首先创建一个形状可绘制对象,它将用作底部工作表的背景:
bg_bottomsheet.xml
android:shape="rectangle">
<>
android:topLeftRadius="@dimen/bottom_sheet_corner_radius"
android:topRightRadius="@dimen/bottom_sheet_corner_radius" />
现在为 BottomSheet 小部件创建自定义样式。
style-v21.xml
styles.xml