在android系统recyclerview海拔阴影多层 [英] Multiple layers of shadows in android recyclerview elevation

查看:382
本文介绍了在android系统recyclerview海拔阴影多层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里输入的形象描述

我与8DP,透明背景的海拔范围为outlineProvider一个recyclerview。 clipToPadding设置为false父RelativeLayout的。我面临的一个奇怪的问题w.r.t由投下的阴影
recyclerview标高。阴影,似乎掩盖了recyclerview的边缘或有是的RelativeLayout和孩子recyclerview(附图片仅供参考)之间的一个额外层。什么是真正造成这种效果呢?我寻觅了很多,但找不到任何explanation.Any建议,欢迎。

 <?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:ID =@ + ID / activity_grid_layout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:clipToPadding =假>< android.support.v7.widget.RecyclerView
    机器人:ID =@ + ID / grid_recycler_view
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:layout_marginBottom =110dp
    机器人:layout_marginLeft =15dp
    机器人:layout_marginTop =80dp
    机器人:背景=@色/透明
    机器人:outlineProvider =界限
    机器人:海拔=8DP
    机器人:填充=0dp
    机器人:滚动条=无/>
< ImageView的
    机器人:ID =@ + ID / grid_main_filter_id
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:填充=10dp
    机器人:layout_alignBottom =@ + ID / grid_recycler_view
    机器人:layout_alignStart =@ + ID / grid_recycler_view
    机器人:layout_marginBottom = - 18dp
    机器人:layout_marginStart =67dp
    机器人:海拔=10dp
    机器人:背景=@绘制/ main_filter/>< ImageView的
    机器人:ID =@ + ID / imageView2
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentBottom =真
    机器人:layout_alignParentStart =真
    机器人:layout_marginBottom =36dp
    机器人:layout_marginLeft =27dp
    机器人:SRC =@绘制/蜂巢/>< ImageView的
    机器人:ID =@ + ID / imageView3
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentBottom =真
    机器人:layout_marginBottom =36dp
    机器人:layout_marginLeft =24dp
    机器人:layout_toEndOf =@ + ID / imageView2
    机器人:SRC =@绘制/挥洒/>< ImageView的
    机器人:ID =@ + ID / imageView4
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentBottom =真
    机器人:layout_marginBottom =36dp
    机器人:layout_marginLeft =24dp
    机器人:layout_toEndOf =@ + ID / imageView3
    机器人:SRC =@绘制/殖民地/>< ImageView的
    机器人:ID =@ + ID / imageView5
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentBottom =真
    机器人:layout_marginBottom =36dp
    机器人:layout_marginLeft =24dp
    机器人:layout_toEndOf =@ + ID / imageView4
    机器人:SRC =@绘制/金库/>< ImageView的
    机器人:ID =@ + ID / imageView6
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentBottom =真
    机器人:layout_alignParentEnd =真
    机器人:layout_marginBottom =36dp
    机器人:layout_marginRight =28dp
    机器人:SRC =@绘制/摄像头/><进度
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:ID =@ + ID /进度
    机器人:layout_centerVertical =真
    机器人:layout_centerHorizo​​ntal =真
    机器人:知名度=水涨船高/>

recycler_view_child_item

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
机器人:填充=0dp>
< ImageView的
    机器人:ID =@ + ID /缩略图
    机器人:layout_width =84dp
    机器人:layout_height =150dp
    机器人:layout_margin =0dp
    机器人:填充=0dp/>
< / LinearLayout中>


解决方案

第一个影子被RecyclerView投,二是由第一ImageView的孩子投在RecyclerView的顶部。这两种阴影看起来不错。也许你可以突出显示,根据你这是不正确的图像的一部分吗?

I have a recyclerview with an elevation of 8dp, transparent background and bounds as outlineProvider. clipToPadding is set to false on the parent relativelayout. I am facing a weird issue w.r.t the shadow cast by the recyclerview elevation. The shadow seems to cover up the edges of the recyclerview or there is an extra layer between the relativelayout and the child recyclerview (Attached an image reference). What is actually causing this effect? I have searched a lot but could not find any explanation.Any suggestions are welcome.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_grid_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">

<android.support.v7.widget.RecyclerView
    android:id="@+id/grid_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="110dp"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="80dp"
    android:background="@color/transparent"
    android:outlineProvider="bounds"
    android:elevation="8dp"
    android:padding="0dp"
    android:scrollbars="none" />


<ImageView
    android:id="@+id/grid_main_filter_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:layout_alignBottom="@+id/grid_recycler_view"
    android:layout_alignStart="@+id/grid_recycler_view"
    android:layout_marginBottom="-18dp"
    android:layout_marginStart="67dp"
    android:elevation="10dp"
    android:background="@drawable/main_filter" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:layout_marginBottom="36dp"
    android:layout_marginLeft="27dp"
    android:src="@drawable/hive" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="36dp"
    android:layout_marginLeft="24dp"
    android:layout_toEndOf="@+id/imageView2"
    android:src="@drawable/sway" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="36dp"
    android:layout_marginLeft="24dp"
    android:layout_toEndOf="@+id/imageView3"
    android:src="@drawable/colony" />

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="36dp"
    android:layout_marginLeft="24dp"
    android:layout_toEndOf="@+id/imageView4"
    android:src="@drawable/vault" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="36dp"
    android:layout_marginRight="28dp"
    android:src="@drawable/camera" />

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:visibility="gone"/>

recycler_view_child_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="0dp">
<ImageView
    android:id="@+id/thumbnail"
    android:layout_width="84dp"
    android:layout_height="150dp"
    android:layout_margin="0dp"
    android:padding="0dp" />
</LinearLayout>

解决方案

The first shadow is cast by the RecyclerView, the second is cast on top of the RecyclerView by the first ImageView child. Both shadows look fine. Maybe you can highlight the part of the image which is not correct according to you?

这篇关于在android系统recyclerview海拔阴影多层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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