【发布时间】:2021-02-18 20:46:45
【问题描述】:
我正在尝试使用具有自定义形状的工具栏,并且我想在 AppBarLayout 下显示 NestedScroll 中的文本。
但我遇到了一些问题,正如您在此屏幕截图中看到的那样:
我怎样才能实现这个目标?
我的 XML:
<androidx.coordinatorlayout.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"
android:background="@android:color/transparent"
android:animateLayoutChanges="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@null"
app:elevation="0dp">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="94dp"
android:background="@drawable/background_header_asset"
app:layout_collapseMode="pin"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ipsun" />
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
PS.:工具栏背景是可绘制的形状,所以它是透明的
编辑:
我的形状是:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="320dp"
android:height="94dp"
android:viewportWidth="320"
android:viewportHeight="94">
<path
android:pathData="M320,73.153L81.283,92.257C64.54,93.42 54.316,94
50.612,94c-3.705,0 -8.826,-1.771 -15.363,-5.314L0,70.176V0h320v73.153z"
android:fillColor="#01874D"
android:fillType="evenOdd"/>
</vector>
【问题讨论】:
标签: android material-design android-coordinatorlayout