【发布时间】:2023-03-27 11:13:01
【问题描述】:
您好,我想从 API 21 及更高版本的工具栏中删除高程和阴影效果。以下是我尝试过的
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setElevation(0);
我的 XML 工具栏。我试图将高度设置为 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
<style name="ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorControlNormal">@android:color/white</item>
</style>
编辑 1:在样式 v21 中尝试了以下内容。结果还是一样
<style name="ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorControlNormal">@android:color/white</item>
<item name="android:elevation">0dp</item>
</style>
编辑 2:工具栏在我的布局中的位置
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