是否可以从 android 中的默认矩形更改 Android 工具栏的形状?

Is it possible to change shape of Android Toolbar from the default rectangle in android?

问题:尝试实现带有拱形底部的工具栏。滚动时的内容应该经过这条弧线space。

有什么建议吗?

这可以很容易地完成。

<android.support.design.widget.CoordinatorLayout
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#0000"
        app:elevation="0dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/colorPrimary"
                app:layout_collapseMode="pin"/>

            <!--Other collapsing toolbar components here-->

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <!--Your content here-->

    </android.support.v4.widget.NestedScrollView>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/curve"
        app:layout_anchor="@id/appBar"
        app:layout_anchorGravity="bottom"
        android:layout_gravity="bottom"/>

</android.support.design.widget.CoordinatorLayout>

锚定在 AppBarLayout 底部的 FrameLayout 作为拱门的容器。我创建了一个矢量可绘制对象,用作 FrameLayout

的背景

curve.xml

<vector android:width="100dp"
    android:height="40dp"
    android:viewportHeight="50"
    android:viewportWidth="400"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <path
        android:pathData="M0,0L400,0L400,50Q200,-50,0,50L0,0"
        android:fillColor="@color/colorPrimary"/>

</vector>

更改 drawable 的 android:height 属性 以控制您希望拱门的高度

输出