【发布时间】:2019-11-11 02:02:38
【问题描述】:
在我的应用程序中,Toolbar 的底部没有显示阴影,我的目标 API 是从 Android 6 M 到 Android 9 P,我正在使用 Android 9 Pie 的设备上测试我的应用程序。
有同样的问题here,但没有答案。
toolbar.xml
<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp">
</androidx.appcompat.widget.Toolbar>
activity_main.xml
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/toolbar"/>
<FrameLayout
android:id="@+id/fragment_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<include layout="@layout/navigation_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
【问题讨论】:
-
将
ToolBar包裹在AppBar中。 -
太棒了。快乐编码
标签: android android-toolbar android-elevation