RecyclerView重叠无阴影

2024-03-10

我想开发像这张图这样的List

我曾经使用 RecyclerView ItemDecoration 进行重叠。但它是重叠的,没有阴影。屏幕和装饰器代码如下

public class OverlapDecoration extends RecyclerView.ItemDecoration {

private final static int vertOverlap = -50;

@Override
public void getItemOffsets (Rect outRect, View view, RecyclerView parent,       RecyclerView.State state) {

outRect.set(0, 0, 0, vertOverlap);
}
}

卡布局.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:tag="cards main container">

<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    card_view:cardBackgroundColor="@color/color_white"
    card_view:cardElevation="5dp"
    card_view:cardUseCompatPadding="true">

            <TextView
                android:id="@+id/textViewName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="30dp"
                android:layout_marginBottom="30dp"
                android:text="Android Name"
                android:textAppearance="?android:attr/textAppearanceLarge"/>

</android.support.v7.widget.CardView>

</LinearLayout>

enter image description heretry this code

卡布局.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:tag="cards main container">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:clipToPadding="false"
        android:elevation="0dp"
        card_view:cardUseCompatPadding="false"
        card_view:paddingEnd="0dp"
        card_view:paddingStart="0dp">

        <TextView
            android:id="@+id/textViewName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:layout_marginTop="30dp"
            android:gravity="center"
            android:text="Android Name"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_above="@id/textViewName"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:background="@drawable/card_shadow" />
    </android.support.v7.widget.CardView>


</RelativeLayout>

用于卡影 卡阴影

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="90"
        android:endColor="#77111111"
        android:startColor="@android:color/transparent" />
</shape>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

RecyclerView重叠无阴影 的相关文章

  • Firebase 管理 SDK Android

    在 Android 中初始化 Firebase Admin SDK 的代码 Override protected void onCreate Bundle savedInstanceState super onCreate savedIns
  • BottomNavigationView - 如何获取选定的菜单项?

    我使用BottomNavigationView来切换片段 如何获取当前选定的菜单项 以防止重新打开片段 BottomNavigationView bottomNavigationView BottomNavigationView findV
  • 使用 Android 前台服务为 MediaPlayer 创建通知

    问题就在这里 我目前正在开发一个应用程序 该应用程序必须提供 A 广播播放器 来自 URL 的 AAC 直播 还有一个播客播放器 来自 URL 的 MP3 流 该应用程序必须能够在后台运行 Android 服务 并通过以下方式向用户公开持续
  • 检测到设备正在振动?

    我使用下面的代码来振动设备 public void vibrator try Vibrator vibrator Vibrator getSystemService Context VIBRATOR SERVICE vibrator vib
  • Android SoundPool 堆限制

    我正在使用 SoundPool 加载多个声音剪辑并播放它们 据我所知 它的功能 100 正确 但在 load 调用期间 我的日志中充斥着以下内容 06 09 11 30 26 110 ERROR AudioCache 23363 Heap
  • 共同的偏好不断消失

    我正在使用共享首选项来存储我的应用程序的登录凭据 除了一个用户之外 一切正常 一段时间后 共享偏好似乎会以某种方式重置或清除 我已针对该用户调整了我的应用程序 使其不再清除他的共享偏好设置 这样我就可以确定这不是我的应用程序的错 但即使在这
  • Delphi XE7 Android 全屏(隐藏软键)

    如何在XE7中全屏显示 隐藏顶部 标题 和底部 软键 工具栏 在 XE6 中 我可以通过在应用程序部分写入来调整 AndroidManifest 以使我的应用程序全屏显示并且没有操作栏 android theme android style
  • 无法在自定义 AOSP 上安装 Google Play 中的某些应用程序:项目不可用。理由:9

    我在尝试从 Google Play 安装某些应用程序时收到以下错误 LibraryUtils isAvailable not available restriction 9 DocUtils getAvailabilityRestricti
  • Android 原理图内容提供程序库配置?

    Jake Wharton 在最近的一次演讲中提到了这个库 它看起来是避免大量样板文件的好方法 所以我尝试了一下 但没有任何成功 https github com SimonVT schematic https github com Simo
  • 获取 AlarmManager 中活动的 PendingIntents 列表

    我有办法获取活动列表PendingIntent在设备中 我开始工作AlarmManager我想看看我的PendingIntents 已正确创建和删除 也很高兴看到其他什么PendingIntent在那里 只是为了看看某些应用程序是否正在做一
  • TextView 之间有分隔线

    我正在尝试在 android studio 中创建以下布局 因为我对 android 东西还很陌生 所以我第一次尝试使用 LinearLayout 并认为这可能无法实现 现在我正在尝试使用RelativeLayout 我已经用颜色创建了这个
  • Firebase:如何在Android应用程序中设置默认通知渠道?

    如何设置default通知渠道通知消息当应用程序在后台运行时会出现什么情况 默认情况下 这些消息使用 杂项 通道 如你看到的在官方文档中 https firebase google com docs cloud messaging andr
  • 请求位置更新参数

    这就是 requestLocationUpdates 的样子 我使用它的方式 requestLocationUpdates String provider long minTime float minDistance LocationLis
  • 在 Jetpack Compose 中启动动画矢量 Drawable

    我有一个动画矢量可绘制R drawable my anim 我想在 Jetpack Compose 中展示并开始 可绘制对象显示 渲染正确 但动画未启动 这是撰写视图 Composable fun SplashView Surface mo
  • ROOM迁移过程中如何处理索引信息

    CODE Entity tableName UserRepo indices Index value id unique true public class GitHubRepo PrimaryKey autoGenerate true p
  • 如何将设备连接到Eclipse?

    我无法解决这个简单的问题 我正在尝试通过 USB 电缆将我的设备连接到 Eclipse 在我的 PC 上 我已经安装了 Eclipse 和 Android SDK 并且在模拟器上运行该程序运行良好 我已在我的电脑上下载并安装了 Samsun
  • 使用 Espresso 检查 EditText 的字体大小、高度和宽度

    如何使用 Espresso 检查 EditText 的字体大小 高度和宽度 目前要分割我使用的文本 onView withId R id editText1 perform clearText typeText Amr 并阅读文本 onVi
  • 在webview android中加载本地html文件

    我正在尝试在 android 的 webview 中加载 html 文件的内容 但是 它给了我 网页不可用错误 如果我尝试使用谷歌或雅虎等网站 它们就会起作用 html文件位于src gt main gt assests gt index
  • 在 Android 中,如何将字符串从 Activity 传递到 Service?

    任何人都可以告诉如何将字符串或整数从活动传递到服务 我试图传递一个整数 setpossition 4 但它不需要 启动时总是需要 0 Service 我不知道为什么我不能通过使用 Service 实例从 Activity 进行操作 publ
  • 找到 Android 浏览器中使用的 webkit 版本?

    有没有办法知道某些特定手机上的 Android 浏览器使用的是哪个版本的 webkit 软件 如果有一个您可以浏览以获取该信息的 URL 那就太好了 但任何其他方式也很好 如果你知道 webkit 版本 你就知道 html5 支持多少 至少

随机推荐

  • 如何正确缩进 Django 模板

    我在 SublimeText 3 中工作 在编写 Django 模板时 我混合了 html 和函数 我喜欢缩进我的代码 以便block if和其他此类声明均缩进 例如 手动格式化 extends accounts base html blo
  • 如何将 CNF 表达式重铸为 3-CNF?

    我有一个像这样的 CNF 表达式 我想将其重新转换为 3 CNF a b c d a b d a b d 有谁知道我该怎么做 A 3 CNF https math stackexchange com questions 56369 can
  • VB.NET - Array.Contains 的替代方案?

    之前 我在 NET Framework 3 5 上使用它并且运行良好 If New String ER PM EM OC Contains Session Position Then Some codes End If 现在我正在做一个使用
  • 模板渲染期间出现异常(“块类型 sonata.Admin.block.admin_list 不存在”)

    Hi我是新来的Symfony2并在生成我的管理面板时面临这个问题 在 SonataAdminBundle Core dashboard html twig 第 35 行渲染模板期间出现异常 块类型 sonata Admin block ad
  • Java(机器人)屏幕截图超出可见范围

    我想立即截取比我的屏幕大的整个网站的屏幕截图 我知道如何使用 Robot 类来截取可见区域的屏幕截图 我认为这样做的一种方法是 启动浏览器 进入所需网站 启动我的程序 程序将截取可见区域的屏幕截图 程序将向下滚动以使页面的后半部分可见并截取
  • EF 4.1 Code First 和现有数据库以及 .NET 成员资格

    我的开发盒上有一个名为 ApplicationName Development 的数据库在 SQL Server 2008 R2 Developer 版本上运行 我将 NET 成员资格表添加到数据库中没有任何问题 当我尝试让 Code Fi
  • 我想删除 HTML 空白

    我有一个新问题困扰着我 我正在制作一个网页 我希望在不滚动的情况下进行修复 最重要的是我希望我的主 Div 填满我的所有可用空间 我做了这个代码
  • 是否允许类型相同但大小不同的双关数组?

    类型相同但大小不同的双关数组仍然违反严格别名吗 int arr 4 int ref 2 reinterpret cast
  • xcode 5 中的 Shell 脚本调用错误

    我在我的项目中使用 openssl 和 sqlcipher 我必须从 Xcode 4 6 升级到 Xcode 5 但是我在 Xcode 5 中编译项目 它给我错误 cp libCrypto a 没有这样的文件或目录 Cp libssl a
  • 用于匹配捕获组中前面或后面的字母字符的正则表达式

    举例来说 我有以下数据 ab cd ef zy ba cd 我希望能够以匹配第一个字符的方式来匹配它 然后根据第一个字符的捕获组匹配第二个字符 上面示例中的每一行都应该匹配 而类似cc or af不应该 详细来说 我的想法看起来像这样 基于
  • HTML img src 返回 404 未找到错误,尽管一切正常

    这是一件令人困惑的事情 首先看我的文件夹的层次结构等 https i stack imgur com b5U8a png并看到图像文件夹下有我的图像 cribbage png 我正在尝试使用 index html 中的以下代码访问此图像 h
  • 在 PostgreSQL 中连接

    我有一个带有宽度和高度 均为整数 的表格 我想按原样显示它 例如 宽度 300 高度 160 面积 300 x 160 我正在使用以下查询 select cast concat width x height as varchar 20 fr
  • 云形成的秘密

    我想坚持 所有基础设施都是代码 的政策 但是 我看不到使用 CloudFormation 来实现机密的方法 SecretsManager 要求您以纯文本形式指定 SecretString 即使您从某处注入解密的值 纯文本字符串也会显示在 C
  • NSIS - 检查注册表项值是否存在

    我需要检查注册表值是否存在 我怎样才能做到这一点 我的第一个方法 ReadRegStr 0 HKLM SOFTWARE Microsoft Windows NT CurrentVersion Ports NUL IF 0 MESSAGEBO
  • Pandas:“item”已被弃用

    到目前为止 我在这里使用了这行代码 max total gross event data max total gross loc event data event id event id item 自从我更新了 Pandas 后 我收到了未
  • MSBuild / Visual Studio 分布式构建

    我开发 维护一个需要很长时间才能构建的应用程序 例如 完整的构建需要超过六个小时 在花了一天的大部分时间构建我们的应用程序之后 我开始研究改进构建时间的方法 建议关于这个堆栈溢出问题 https stackoverflow com ques
  • JavaFX:在拖放过程中更改光标

    我试图在拖放过程中更改节点上的光标 但图像没有改变 我正在打电话setCursor in the DragDetectedEventHandler我的节点 我也尝试过打电话getParent setCursor 并得到相同的结果 我还尝试在
  • 未定义行为 (UB) 以实现余地为条件的程序是具有无条件 UB 的程序吗?

    在回答中 在 C 20 中使用 std bit cast 创建闭包 lambda 对象是否有效 https stackoverflow com questions 68828838 is it valid to create closure
  • Silverstripe 后端发生奇怪的行为?

    突然间 每当我尝试单击 silverstripe 后端中的页面时 它最初会显示如下 我正在运行 SS 3 2 当这种情况开始发生时 我升级到 3 2 1 看看是否可以解决问题 但不行 有时它也会显示此错误消息 User Warning Co
  • RecyclerView重叠无阴影

    我想开发像这张图这样的List 我曾经使用 RecyclerView ItemDecoration 进行重叠 但它是重叠的 没有阴影 屏幕和装饰器代码如下 public class OverlapDecoration extends Rec