为什么在Android中无法删除工具栏阴影? [英] Why does Toolbar shadow not removing in Android?
问题描述
我正在尝试删除工具栏底部的阴影.我已将 android:elevation ="0dp" 应用于AppBar和工具栏仍然无法正常工作.
我在本文中针对
问题已通过在AppBar布局中添加以下行来解决.无需设置海拔高度.
android:stateListAnimator =" @ null"
< com.google.android.material.appbar.AppBarLayoutandroid:stateListAnimator =" @ null"android:layout_width =" match_parent"android:layout_height =" wrap_content">../>
I am trying to remove the Toolbar bottom shadow. I have applied android:elevation="0dp" to the both AppBar and Toolbar still not working.
I have applied the different solutions in this post for Remove shadow between Toolbar and TabLayout removing shadow still no effect.
My MainActivity.xml code: : which is having Toolbar
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
android:fitsSystemWindows="true"
android:background="?attr/activityBackground"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:elevation="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:elevation="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:titleTextColor="?toolbarTitleColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/toolbarColor"
android:id="@+id/toolbar1"
app:title="Home">
.
.
.
/>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:layout_marginBottom="56dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/birthdayFragmentHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
TabLayout fragment code: replaced when bottom nav Tab clicked.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Fragments.HomeTab.HomeFragment">
<com.google.android.material.tabs.TabLayout
android:id="@+id/homeFragmentTabs"
android:background="?attr/postCardBackground"
app:tabTextColor="?attr/postUserNameColor"
app:tabSelectedTextColor="?attr/toolbarTitleColor"
app:tabIndicatorColor="?attr/toolbarTitleColor"
app:tabRippleColor="?attr/toolbarTitleColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.viewpager.widget.ViewPager
android:layout_below="@+id/homeFragmentTabs"
android:id="@+id/homeFragmentViewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Output Image:
Problem was solved by adding below line in the AppBar Layout. No need to set elevation.
android:stateListAnimator="@null"
<com.google.android.material.appbar.AppBarLayout
android:stateListAnimator="@null"
android:layout_width="match_parent"
android:layout_height="wrap_content">
.
.
/>
这篇关于为什么在Android中无法删除工具栏阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!