【问题标题】:How to remove toolbar shading如何去除工具栏阴影
【发布时间】:2020-11-04 15:37:53
【问题描述】:

在这张图片中你可以看到工具栏的阴影,我想去掉这个阴影。

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/Theme.AIT.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#2398f4"
            app:popupTheme="@style/Theme.AIT.PopupOverlay"
            app:elevation="0dp"/>

    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_main" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

这是工具栏的xml文件。另外请告诉我如何将这个主页标题设置为中心。

【问题讨论】:

标签: android android-layout


【解决方案1】:

在工具栏 xml 中将高度设置为 0dp。

// 这是替代方法 你也可以实现 ((AppCompatActivity)getActivity()).getSupportActionBar().setElevation(0);在主 java 文件中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 2016-10-27
    • 2017-07-13
    • 1970-01-01
    • 2019-12-23
    相关资源
    最近更新 更多