android - CardView 在 Pre-Lollipop 的每个边缘都有额外的边距

标签 android android-5.0-lollipop android-cardview

这是两张照片。

在 Lollipop 上: on Lollipop:

在 Lollipop 前: on Pre-Lollipop

我们可以看到它只是靠近 Lollipop 的屏幕一侧。这就是我想要的。但在 Pre-Lollipop 设备上,它在屏幕边缘有额外的边距。你们有什么经验吗?谢谢。

这是布局xml:

<android.support.v7.widget.CardView
        android:id="@+id/card_title_schedule"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        app:cardCornerRadius="0dp"
        app:cardBackgroundColor="@color/colorAccent"
        >

最佳答案

所以在这里它在 Kitkat 上运行得非常好,准确地说是三星设备。

我试过 card_view:cardUseCompatPadding="true" 但无济于事。没用!

然后我从 stackoverflow 帖子中发现了这个 card_view:cardPreventCornerOverlap="false" 瞧!工作!没有圆角(因为卡片有图像背景,所以我不想要)。

道德是,额外的填充是因为那些需要禁用的小圆角。基本上这不是缺陷,而是设计约束!

ORIGINAL SOF REPLY

Image:请注意,顶角是边缘(背景中具有颜色和图像的 View ),而底部只有 TextViews 而没有背景,因此是圆角。这意味着,如果 View 在 CardView 内请求 match_parentcard_view:cardPreventCornerOverlap="false" 将允许在受影响的角上占用它。

enter image description here

关于android - CardView 在 Pre-Lollipop 的每个边缘都有额外的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29068430/

相关文章:

java - 在 RecyclerView 中设置 CardView 的背景图片会导致程序在滚动时崩溃

java - 错误 : "' void RecyclerView. setLayoutManager(RecyclerView$LayoutManager )' on a null object reference"

android - 我们如何通过组合不同的模块来创建一个单一的库?

android - 监控android中正在运行的应用程序

android - 如何在 Android 中禁用 Lollipop 转场动画

android - Cardview 内容似乎没有正确加载或充气,没有错误

android - 如何将 RelativeLayout 的宽度设置为与兄弟 View 相同?

android - 尝试初始化 AudioRecord 时出现 "Could not get audio input for record source 1"

android - 尝试构建共享元素 Lollipop 过渡时过渡名称为空

android - Android 中两个不同应用程序之间的共享元素转换?