CardView 顶部和底部的额外填充
Extra padding at top and bottom in CardView
我正在使用 recyclerview 显示来自网络服务的图像列表。我正在尝试在 CardView widget.Everything 中的 ImageView 中显示图像工作正常。所有图像和列表都正确显示。但是当我尝试在 Kitkat 4.4.4 上 运行 时,它在 Cardview 中图像的顶部和底部显示额外的(大)填充。我只使用 ImageView,没有文字。
检查附件图像。
4.4.4
在棒棒糖上
到目前为止,我已经尝试了几乎所有我在 SO 上找到的东西。
任何帮助表示赞赏。
谢谢
XML Cardview 代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin_half">
<android.support.v7.widget.CardView
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/offwhite"
android:id="@+id/cardlayout_malls"
android:layout_marginLeft="@dimen/activity_horizontal_margin_half"
card_view:cardUseCompatPadding="true"
android:layout_marginRight="@dimen/activity_horizontal_margin_half">-->
<!-- Thumbnail Image -->
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bannerImageView"/>
</android.support.v7.widget.CardView>
</RelativeLayout>
试试这个方法
card_view:cardPreventCornerOverlap="false"
或
在图像视图中,您可以使用将其添加到图像视图中
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:id="@+id/bannerImageView"/>
添加card_view:cardPreventCornerOverlap="false"
额外的填充是因为那些需要禁用的微小圆角。基本上这不是缺陷而是设计限制!
我正在使用 recyclerview 显示来自网络服务的图像列表。我正在尝试在 CardView widget.Everything 中的 ImageView 中显示图像工作正常。所有图像和列表都正确显示。但是当我尝试在 Kitkat 4.4.4 上 运行 时,它在 Cardview 中图像的顶部和底部显示额外的(大)填充。我只使用 ImageView,没有文字。
检查附件图像。
4.4.4
在棒棒糖上
XML Cardview 代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin_half">
<android.support.v7.widget.CardView
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/offwhite"
android:id="@+id/cardlayout_malls"
android:layout_marginLeft="@dimen/activity_horizontal_margin_half"
card_view:cardUseCompatPadding="true"
android:layout_marginRight="@dimen/activity_horizontal_margin_half">-->
<!-- Thumbnail Image -->
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bannerImageView"/>
</android.support.v7.widget.CardView>
</RelativeLayout>
试试这个方法
card_view:cardPreventCornerOverlap="false"
或
在图像视图中,您可以使用将其添加到图像视图中
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:id="@+id/bannerImageView"/>
添加card_view:cardPreventCornerOverlap="false"
额外的填充是因为那些需要禁用的微小圆角。基本上这不是缺陷而是设计限制!