cuốn sách gpt4 ai đã làm

android - BottomSheet - 不正确的设计行为

In lại Tác giả: Walker 123 更新时间:2023-11-29 01:01:44 27 4
mua khóa gpt4 Nike

我一直在尝试设置 Bottomsheet Google 在他们的应用程序(例如 GOOGLE NEWS 等)中使用的方式,

This is how Google's Bottomsheet looks like the following

nhập mô tả hình ảnh ở đây

Where my Bottomsheet looks like the following

nhập mô tả hình ảnh ở đây

马上你会注意到两件事,

  1. 没有圆角
  2. 底部导航未混合

我的 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







Xem sitemap của VNExpress