How to get rid of the shadow between AppBarLayout and TabLayout?

前端 未结 4 1366
粉色の甜心
粉色の甜心 2021-01-28 05:20

I have a layout for a fragment with three tabs. The XML code of the layout is as follows:




        
相关标签:
4条回答
  • 2021-01-28 05:31

    Use app:elevation="0dp" in your AppBarLayout

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="52dp"
        app:elevation="0dp"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
    

    or Use getSupportActionBar().setElevation(0); in your actvity

    0 讨论(0)
  • 2021-01-28 05:32

    Open app_bar_main.xml and set app:elevation="0dp" inside AppBarLayout, then clean and rebuild project.

    <android.support.design.widget.AppBarLayout
    

    ... app:elevation="0dp">

    </android.support.design.widget.AppBarLayout>
    
    0 讨论(0)
  • 2021-01-28 05:38

    If android:elevation didn't work then try app:elevation:

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="52dp"
        android:elevation="0dp"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
    

    Try with CoordinatorLayout instead of Constraintlayout.

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.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:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context=".fragment.PatternAssignmentFragment">
    
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="52dp"
            android:paddingTop="@dimen/appbar_padding_top"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:elevation="0dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">
    
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:layout_editor_absoluteY="8dp">
    
                <android.support.design.widget.TabItem
                    android:id="@+id/tabItem"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/tab_text_1" />
    
                <android.support.design.widget.TabItem
                    android:id="@+id/tabItem2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/tab_text_2" />
    
                <android.support.design.widget.TabItem
                    android:id="@+id/tabItem3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/tab_text_3" />
    
            </android.support.design.widget.TabLayout>
        </android.support.design.widget.AppBarLayout>
    
        <android.support.v4.view.ViewPager
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/appbar" />
    
    
    </android.support.design.widget.CoordinatorLayout>
    
    0 讨论(0)
  • 2021-01-28 05:51

    Use app:elevation="0dp" instead of android:elevation="0dp"

    0 讨论(0)
提交回复
热议问题