代码之家  ›  专栏  ›  技术社区  ›  alashow

用于底部应用程序栏的样式工具栏

  •  1
  • alashow  · 技术社区  · 6 年前

    this style 如底部应用程序栏的材料指南所示?

    它的白色,没有海拔,有更多的标题顶部填充比平常等,我找不到任何规格为它在材料指南或任何主题参考 material-components-android

    截图: material design guidelines

    1 回复  |  直到 6 年前
        1
  •  0
  •   ʍѳђઽ૯ท    6 年前

    所以,你想达到白种人的目标 Toolbar 具有 BottomAppBar

    为此,添加 AppBarLayout 工具栏 在里面 CoordinatorLayout ,放置 底部AppBar FloatingActionButton 并设置 app:layout_anchor 的属性 浮动操作按钮 引用的id 具体如下:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
        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="match_parent"
        tools:context=".MainActivity">
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/yourwhitebackground"
        app:elevation="0dp">
    
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/yourwhitebackground"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways"
            />
    </android.support.design.widget.AppBarLayout>
    
        <android.support.design.bottomappbar.BottomAppBar
            android:id="@+id/bottom_appbar"
            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/colorPrimary"
            app:fabCradleVerticalOffset="12dp">
    
        </android.support.design.bottomappbar.BottomAppBar>
    
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:src="@drawable/ic_add_white_24dp"
            app:layout_anchor="@+id/bottom_appbar"/>
    
    
    </android.support.design.widget.CoordinatorLayout>
    

    https://medium.com/@lupajz/the-place-for-bottomappbar-31e0db8f70b1 更多细节。

    app:elevation 可能不起作用,请尝试以下操作: https://stackoverflow.com/a/45703684/4409113

    推荐文章