android - CardView 不屏蔽父级内部
问题描述
我想放CardView
里面Rounded LinearLayout
。但是我的布局仍然是方形的,但是如果我放置另一个视图,它是圆形的。
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/rounded">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
app:cardPreventCornerOverlap="false" />
</LinearLayout
这是我的圆形布局
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<stroke
android:width="3dp"
android:color="@color/white" />
<corners android:radius="8dp"/>
</shape>
我尝试使用app:cardPreventCornerOverlap="false"
但仍然无法正常工作。我的卡如何变成圆形,因为它在圆形的父级内?
我尝试了另一种方法。
我使用 CardView 和实现更改父级app:cardCornerRadius
<android.support.v7.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="8dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
app:cardPreventCornerOverlap="false" />
</LinearLayout
但还是一样,CardView
孩子覆盖CardView
父母
解决方案
给 相等的半径CardView
。
<LinearLayout
...>
<android.support.v7.widget.CardView
app:cardCornerRadius="8dp"
... />
</LinearLayout
推荐阅读
- swift - 如何从另一个视图swiftui中传递字段文本值
- python - 处理结构数据的最佳策略?
- html - 通过视口元标记进行 Ionic v4 页面缩放
- json - 雪花:如何在外部 S3 阶段创建 json 文件的视图
- javascript - 使用多个参数从 HTML 调用 javascript 函数
- java - 在 selenium java POM 项目中不使用 testng.xml 文件并且仅使用 pom.xml 文件可以执行吗?
- android - 如何以编程方式更改 Android App 中 Activity 的语言环境
- javascript - 有没有更好的方法来提高在一个对象中包含多个数组的算法的复杂性
- json - 是否有用于过滤 JSON pcap 的工具或 wireshark 插件?
- powershell - 在 AD 查询上使用 Foreach-Object,比较管道变量