android - Android BottomSheet 灰色抓斗/把手
问题描述
在一些流行的应用程序中,我在 BottomSheets 上看到过这种灰色把手装饰。这是 Google 地图中的 BottomSheet 的屏幕截图。注意底部表顶部的灰色手柄/抓手。
实现这样的装饰或背景的最佳方法是什么?这种装饰有标准材质或安卓风格吗?
解决方案
我将用于抓斗/手柄的 SVG 插入到我的底部表单布局中。
MyBottomSheetDialogFragmentLayout.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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="wrap_content">
<ImageView
android:id="@+id/bottomSheetGrapple"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/topMargin"
android:src="@drawable/ic_bottom_sheet_grapple"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
.... // rest of layout
</androidx.constraintlayout.widget.ConstraintLayout>
ic_bottom_sheet_grapple.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="3dp"
android:viewportWidth="24"
android:viewportHeight="3">
<path
android:fillColor="@android:color/darker_gray"
android:pathData="M 1.5 0 L 22.5 0 Q 24 0 24 1.5 L 24 1.5 Q 24 3 22.5 3 L 1.5 3 Q 0 3 0 1.5 L 0 1.5 Q 0 0 1.5 0 Z"
android:strokeWidth="1" />
</vector>
推荐阅读
- algorithm - 识别二维多边形的最相关顶点
- git - 分布式版本控制系统中无可争议的代码时间戳
- javascript - 从谷歌电子表格中的单元格调用 showSidebar()
- javascript - Javascript 调整元素大小
- javascript - 异步等待调用
- bash - 在 Mac 上:我可以创建一个快捷键来根据剪贴板内容运行 bash 代码吗
- azure - 在 .Net Core 中将登录与 Azure Active Directory 集成
- java - Hibernate 在 Java Main Class 中工作,但如果通过 Managedbean 连接到 JSF 表单则不起作用
- wordpress - 有没有办法可以自定义一个 Electro 主题的 WordPress 网站标头?
- javascript - 在 v8 中实现无限列表