Android-删除工具栏和TabLayout之间的阴影 [英] Android - Remove shadow between Toolbar and TabLayout

查看:98
本文介绍了Android-删除工具栏和TabLayout之间的阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CollapsingToolbarLayout进行布局.但是我一无所获.我要删除工具栏和TabLayout之间的阴影.我尝试了几种方法,但没有设法消除阴影.有谁能够帮我?谢谢

I'm trying to make a layout with CollapsingToolbarLayout. But I do not get one thing. I want to remove the shadow between Toolbar and TabLayout. I've tried several ways and I have not managed to remove the shadow. Can anybody help me? Thank you

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@android:color/white"
android:fitsSystemWindows="true">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/adview"
    android:fitsSystemWindows="true">

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="50dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_gravity="bottom"
        android:background="?attr/colorPrimary"
        android:translationZ="2dp"
        app:layout_anchor="@+id/appbar"
        app:layout_anchorGravity="bottom"
        app:tabGravity="fill"
        app:tabIndicatorColor="@android:color/white"
        app:tabIndicatorHeight="3dp"
        app:tabMode="fixed"
        app:tabTextColor="@color/tabs_text_selector" />

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="20dp"
            app:expandedTitleMarginStart="20dp"
            app:expandedTitleTextAppearance="@style/detalle_txt_expanded"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/detalle_img"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/img_thumb_m"
                android:transitionName="@string/transition"
                app:layout_collapseMode="parallax"
                tools:targetApi="lollipop" />

            <ImageView
                android:id="@+id/detalle_img_tipo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="15dp"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/img_edificio"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme"/>

        </net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/detalle_info_fab_check"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:clickable="false"
        android:src="@drawable/ic_check1"
        app:fabSize="mini"
        app:backgroundTint="@android:color/white"
        app:layout_anchor="@+id/appbar"
        app:layout_anchorGravity="bottom|right|end" />

</android.support.design.widget.CoordinatorLayout>

<include
    android:id="@+id/adview"
    layout="@layout/adview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />

推荐答案

尝试为AppBarLayout设置app:elevation="0dp"(而不是android:elevation).

Try setting app:elevation="0dp" (not android:elevation) for your AppBarLayout.

如果您的xml中没有应用程序名称空间,请添加xmlns:app="http://schemas.android.com/apk/res-auto".

In case you don't have the app namespace in your xml, add xmlns:app="http://schemas.android.com/apk/res-auto".

这两个属性之间的区别可以在此处找到.

The difference between these two properties can be found here.

在那之后,请检查您是否没有添加具有以下任一属性的背景/边框:

After that, check that you're not adding some background/border with any of these properties:

 <android.support.design.widget.TabLayout
    android:background="?attr/colorPrimary"
    android:translationZ="2dp"
    app:layout_anchor="@+id/appbar"
    app:layout_anchorGravity="bottom"
    app:tabGravity="fill"
    app:tabIndicatorColor="@android:color/white"/>

或您用于AppBarLayout的主题.

这篇关于Android-删除工具栏和TabLayout之间的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆