【发布时间】:2017-08-21 06:38:50
【问题描述】:
我正在使用 recyclerview 来显示来自网络服务的图像列表。我正在尝试在 CardView 小部件中的 ImageView 中显示图像。一切正常。所有图像和列表都正确显示。但是当我尝试在 Kitkat 4.4.4 上运行时,它会在 Cardview 中图像的顶部和底部显示额外的(大)填充。我只使用 ImageView,没有任何文字。
检查附件。
在棒棒糖上 到目前为止,我已经尝试了几乎所有我在 SO 上找到的东西。 任何帮助表示赞赏。 谢谢
Cardview 的 XML 代码
<?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>
【问题讨论】:
-
显示你的 xml 文件
-
您是否在适配器的 XML 文件中使用 match_parent,如果是,则将其更改为 wrap_content
-
请张贴xml代码
-
@RakshitNawani 我使用 wrap_content 作为高度,使用 match_parent 作为宽度
-
@deejay : 请分享您的 XML 代码以便更好地理解
标签: android android-layout android-imageview padding android-cardview