【问题标题】:How to remove shadow between toolbar and tablayout?如何去除工具栏和tablayout之间的阴影?
【发布时间】:2020-07-16 00:16:55
【问题描述】:

我想去除工具栏和tablayout之间的阴影,但保留tablayout下的阴影。我怎么能做这件事?我尝试了几种方法,但仍然无法解决这个问题。

我的activity_mail.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
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">

<androidx.appcompat.widget.Toolbar
    android:id="@+id/mainToolbar"
    style="@style/mainToolbar"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.appcompat.widget.AppCompatImageView
        android:layout_width="140dp"
        android:layout_height="35dp"
        android:layout_marginStart="-20dp"
        android:src="@drawable/logo" />
</androidx.appcompat.widget.Toolbar>
<!--    TabLayout-->

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorAccent"
    android:elevation="10dp"
    app:layout_constraintTop_toBottomOf="@id/mainToolbar">

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/mainTab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        android:elevation="10dp"
        app:tabIndicatorAnimationDuration="1"
        app:tabIndicatorColor="@color/colorPrimary"
        app:tabIndicatorFullWidth="true"
        app:tabIndicatorHeight="3dp"
        app:tabInlineLabel="true"
        app:tabMode="fixed"
        app:tabRippleColor="@color/colorPrimary"
        app:tabSelectedTextColor="@color/colorPrimary"
        app:tabTextAppearance="@style/customTabStyle"
        app:tabTextColor="@color/colorBlack" />
</com.google.android.material.appbar.AppBarLayout>

This problem

【问题讨论】:

标签: android kotlin android-tablayout elevation


【解决方案1】:

在您的AppBarLayout 添加0dp 海拔

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorAccent"
    android:elevation="0dp"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    相关资源
    最近更新 更多