首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于前棒棒糖的表格布局阴影/立面

用于前棒棒糖的表格布局阴影/立面
EN

Stack Overflow用户
提问于 2016-09-21 06:56:32
回答 1查看 828关注 0票数 0

我在AppBarLayout中有一个表格布局。我正在尝试添加一个阴影视图下的标签栏布局,为前棒棒糖版本。阴影视图显示出来,但是当我向下滚动时,阴影视图看起来并不透明。它看起来就像是在tablayout下面,the指示器和阴影之间有一个填充。然而,如果我在工具栏下面使用相同的阴影视图,当我向上滚动时,它似乎是透明的。有没有人能告诉我有没有什么不同的地方可以为版面添加阴影?

主布局-

代码语言:javascript
复制
<android.support.v4.widget.DrawerLayout     
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/drawer_layout"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:fitsSystemWindows="true">

 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical">

        <include layout="@layout/include_coordinator_layout"/>

    </LinearLayout>

    <TextView
        android:id="@+id/mtext_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:gravity="center"
        android:visibility="gone"/>

    <Button
        android:id="@+id/mBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_below="@id/mtext_view"
        android:text="@string/retry_button"
        android:visibility="gone"/>
</RelativeLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navView"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/white"
    android:fitsSystemWindows="true" />

</android.support.v4.widget.DrawerLayout>

这是我的include_coordinator_layout

代码语言:javascript
复制
<?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"
     android:id="@+id/main_content"
   android:layout_width="match_parent"
   android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
       android:id="@+id/appbar"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">

    <include
        android:id="@+id/toolbar"
        layout="@layout/tool_bar" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMaxWidth="0dp"
        app:tabGravity="fill"
        app:tabMode="fixed"
        android:background="@color/tab_layout_color"/>

    <View
        android:id="@+id/shadow_view"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:background="@drawable/toolbar_shadow"
        />

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

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

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

这是我的toolbar_shadow可绘制的。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="@android:color/transparent"
        android:endColor="#88333333"
        android:angle="90"/>
</shape>
EN

回答 1

Stack Overflow用户

发布于 2016-09-21 08:19:15

我猜您在LinearLayout中有自己的布局

任一

将LinearLayout更改为RelativeLayout并将android:layout_below="@+id/appbar"android:paddingTop="-5dp"android:clipToPadding="false"添加到您的ViewPager (或使用ConstraintLayout和类似方法),切换工具栏和视图分页的顺序

将其更改为FrameLayout,重新排序视图,使ViewPager位于第一位,然后将android:layout_marginTop="@dimen/sizeOfToolBarAndTabsWithoutShadow"放在其中,其中dimen是工具栏和选项卡的设置大小(无阴影)。您可能想要这样做,因为我似乎记住了一些带有滚动视图和clipToPadding的视觉工件

为什么?

因为AppBarLayout视图的大小包括您的阴影,所以任何基本视图组(LinearLayout)都不知道如何布置下一个视图(您的视图分页程序),以便阴影与必须最后绘制的内容略有重叠,这样视图分页程序的顶部就不会覆盖阴影

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39604963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档