android - 背景卡片视图形状未定义
问题描述
我定义了一个类似于下图的 CardView,但它后面还有一个尚未定义的形状(红色箭头)。我知道 CardView 是造成问题的原因,因为如果你用 LinearLayout 替换它就没有问题。使用 Layout Inspector 我也看不到这个形状,有谁知道它是否是导致不需要的形状出现的 cardView 的规范?
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/Transparent"
app:cardPreventCornerOverlap="false"
app:cardCornerRadius="16dp"
app:cardElevation="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
更新: 将高程值设置为较高的值,例如 128dp,不会出现问题。这不是理想的解决方案,但它解决了
解决方案
您可以按形状创建这个圆角背景。例子:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:tint="@color/base_color">
<corners android:radius="@dimen/corners_radius" />
</shape>
我不是 100% 肯定,但我认为它是由海拔高度引起的。
推荐阅读
- android - Android,颤动错误:任务':app:mergeDebugResources'的执行失败
- jmeter - Jmeter如何读取csv文件中的文件路径
- python - 如何在另一个类的函数中从一个类调用对象
- ruby-on-rails - 如何更改活动管理员输入按钮文本
- pixi.js - PixiJS:具有两种不同的抗锯齿渲染器
- mysql - MySQL从表A和表B插入表C
- jenkins - Jenkins插件将文件复制到Windows服务器
- javascript - Javascript - 无法访问动态创建的元素
- python - 如何使用 python pandas 替换列中的特定数字。
- compilation - Webmin Windows 安装程序报告没有 ActiveState Perl