工具栏未在Android 9,API 28中显示海拔 [英] Toolbar not showing elevation in Android 9, API 28
本文介绍了工具栏未在Android 9,API 28中显示海拔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用中,工具栏
底部没有显示阴影,我的目标API来自 Android 6 M
到 Android 9 P
,我正在具有 Android 9 Pie
的设备上测试我的应用。
In my app, the Toolbar
is not showing shadow at its bottom, my target API is from Android 6 M
to Android 9 P
, I am testing my app on device having Android 9 Pie
.
在此处有一个相同的问题,但没有答案。
There is a same question here but no answer.
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>
推荐答案
您可以这样实现-
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<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>
这篇关于工具栏未在Android 9,API 28中显示海拔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文