Android:我无法删除工具栏上的高程/阴影 [英] Android: I cannot remove elevation / shadow on my toolbar
本文介绍了Android:我无法删除工具栏上的高程/阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的工具栏中删除API 21及更高版本的高程和阴影效果.以下是我尝试过的内容
Hi i would like to remove the elevation and shadow effect from my toolbar for API 21 and greater. Below is what i have tried
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setElevation(0);
我的XML工具栏.我试图将海拔高度设置为0dp
My Toolbar in XML. I have tried to set elevation to 0dp
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:elevation="0dp"
android:theme="@style/ToolbarStyle"
app:theme="@style/ToolbarStyle"
>
如果有帮助,这就是ToolbarStyle
And this is ToolbarStyle if it helps
<style name="ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorControlNormal">@android:color/white</item>
</style>
在v21样式中尝试了以下内容.结果还是一样
<style name="ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorControlNormal">@android:color/white</item>
<item name="android:elevation">0dp</item>
</style>
工具栏在我的布局中的位置
android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/toolbar" />
推荐答案
您可以轻松完成此操作.不要从布局中删除android.support.design.widget.AppBarLayout
,而是向其中添加属性app:elevation="0dp"
.您的最终布局将是:
You can do that with an easy step. Don't remove the android.support.design.widget.AppBarLayout
from your layout, instead add the attribute app:elevation="0dp"
to it. Your final layout will be:
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
...
</android.support.design.widget.AppBarLayout>
这篇关于Android:我无法删除工具栏上的高程/阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文