如何删除工具栏阴影

时间:2020-11-04 15:37:53

标签: android android-layout

enter image description here

在此图片中,您可以看到工具栏的阴影,我要删除此阴影。

<?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文件。另外,请告诉我如何将此“首页”标题设置为居中。

1 个答案:

答案 0 :(得分:1)

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

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