首先,很抱歉提出这样的问题,但是在我下载了最新的Google IO
应用程序后,
我只是喜欢底部布局,如下面的屏幕截图所示
作为android开发的新手,我不知道从哪里开始,知道如何在XML中用圆星实现这个底部布局吗?有谁知道这个设计叫什么名字?
首先,很抱歉提出这样的问题,但是在我下载了最新的Google IO
应用程序后,
我只是喜欢底部布局,如下面的屏幕截图所示
作为android开发的新手,我不知道从哪里开始,知道如何在XML中用圆星实现这个底部布局吗?有谁知道这个设计叫什么名字?
您可以使用适用于 Android 的新材料组件和BottomAppBar
组件。
使用类似的东西:
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
android:layout_gravity="bottom"
app:fabCradleMargin="8dp"
app:fabCradleRoundedCornerRadius="8dp"
app:fabCradleVerticalOffset="0dp"
... />
<com.google.android.material.floatingactionbutton.FloatingActionButton
app:layout_anchor="@id/bar"
../>
您必须使用这些属性:
fabCradleMargin
属性。它增加或减少之间的FloatingActionButton
距离BottomAppBar
fabCradleRoundedCornerRadius
属性。它指定切口周围角的圆度旧支持库
对于支持库 28.0.0,设计库包含BottomAppBar
.
您可以使用
<android.support.design.bottomappbar.BottomAppBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:backgroundTint="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
您可以使用以下属性自定义组件:
app:fabAlignmentMode
:声明已附加到底部应用栏的 FAB 的位置。这可以是end
或者center
app:fabCradleVerticalOffset
:声明要用于附加晶圆厂的垂直偏移量。默认情况下这是 0dp。
app:backgroundTint
:用于对视图的背景应用色调。
此外,您可以app:layout_anchor
使用底部应用栏的 ID 在您希望附加的 FAB 组件上附加一个晶圆厂。
我相信它是BottomAppBar
支持库 28.0.0 中的 ,。您可以在此处阅读更多信息:https ://medium.com/@lupajz/the-place-for-bottomappbar-31e0db8f70b1
应用栏:底部
底部应用栏提供对底部导航抽屉和最多四个操作的访问,包括浮动操作按钮。
底部应用栏可以包含适用于当前屏幕上下文的操作。它们包括最左侧的导航菜单控件和浮动操作按钮(如果存在)。如果包含在底部应用程序栏中,则会在其他操作的末尾放置一个溢出菜单控件。
<android.support.design.widget.FloatingActionButton
android:id="@+id/FloatingActionButtonAddEmp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
app:srcCompat="@drawable/ic_save_black_24px"
app:layout_anchor="@+id/bottom_appbar"/>
<android.support.design.bottomappbar.BottomAppBar
android:id="@+id/bottom_appbar"
android:elevation="4dp"
style="@style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:fabAttached="true"
app:backgroundTint="@color/io15_grey"/>