如何摆脱AppBarLayout和TabLayout之间的阴影? [英] How to get rid of the shadow between AppBarLayout and TabLayout?
本文介绍了如何摆脱AppBarLayout和TabLayout之间的阴影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有三个标签的片段布局.布局的XML代码如下:
<?xml version ="1.0" encoding ="utf-8"?>< android.support.constraint.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:id ="@ + id/main_content"android:layout_width ="match_parent"android:layout_height ="match_parent"android:fitsSystemWindows ="true"工具:context =.fragment.PatternAssignmentFragment">< android.support.design.widget.AppBarLayoutandroid:id ="@ + id/appbar"android:layout_width ="match_parent"android:layout_height ="52dp"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">< android.support.design.widget.TabLayoutandroid:id ="@ + id/tabs"android:layout_width ="match_parent"android:layout_height ="match_parent"工具:layout_editor_absoluteY ="8dp">< android.support.design.widget.TabItemandroid:id ="@ + id/tabItem"android:layout_width ="wrap_content"android:layout_height ="wrap_content"android:text ="@ string/tab_text_1"/>< android.support.design.widget.TabItemandroid:id ="@ + id/tabItem2"android:layout_width ="wrap_content"android:layout_height ="wrap_content"android:text ="@ string/tab_text_2"/>< android.support.design.widget.TabItemandroid: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.ViewPagerandroid: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.constraint.ConstraintLayout>
在AppBarLayout和TabLayout之间显示阴影,如图像所示(红线上方的阴影):
我尝试了xml中的各种调整以将其删除,但是似乎没有任何效果.任何建议将不胜感激!
解决方案
使用 app:elevation ="0dp"
代替 android:elevation ="0dp"
>
I have a layout for a fragment with three tabs. The XML code of the layout is as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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: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: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.constraint.ConstraintLayout>
There is a shadow showing between the AppBarLayout and TabLayout, as can be seen in the image (shadow above the red line):
I have tried various tweaks in the xml to remove it, but nothing seems to be working. Any suggestions would be greatly appreciated!
解决方案
Use app:elevation="0dp"
instead of android:elevation="0dp"
这篇关于如何摆脱AppBarLayout和TabLayout之间的阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文