【问题标题】:how i can delete extras margin in CardView inside RecyclerView我如何在 RecyclerView 内的 CardView 中删除额外边距
【发布时间】:2018-03-07 10:36:48
【问题描述】:

如何删除这个额外的边距,我尝试使用this 回答但不起作用。

我的代码 CardView

< LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: card_view = "http://schemas.android.com/apk/res-auto"
xmlns: tools = "http://schemas.android.com/tools"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content" >

 < android.support.v7.widget.CardView
android: id = "@+id/cartaExposicion"
android: layout_width = "wrap_content"
android: layout_height = "300dp"
card_view: cardPreventCornerOverlap = "false" >

 < ImageView
android: id = "@+id/imgExposicion"
android: layout_width = "wrap_content"
android: layout_height = "300dp"
android: src = "@mipmap/makuma_0salas" / >
 < /android.support.v7.widget.CardView> < /LinearLayout>

编辑

我需要删除卡片视图中的间距

【问题讨论】:

  • 你指的额外边距是多少?您是指 CardView 之间的间距吗?
  • 是的@Knossos,CardViews 之间的间距是正确的
  • @Knossos 对不起,它在卡片视图中的间距,我怎样才能删除这个间距?
  • 看起来您正在为ImageViewCardView 设置300dp,但填充它的图像实际上并不是300dp 的高度。所以它不能满足这种观点。尝试将 ImageViewCardView 都设置为 wrap_content 的高度。或者尝试将ImageView scaleType 设置为fit

标签: java android android-recyclerview android-cardview


【解决方案1】:

尝试为卡片视图内容填充提供负值

card_view:contentPadding="-5dp"

如果您想不均匀地删除填充。尝试为 contentPaddingLeft、contentPaddingRight、contentPaddingBottom 和 contentPaddingTop 赋予不同的值。

希望这对你有用。

【讨论】:

    【解决方案2】:

    我解决了我的问题,图像的尺寸很大,我使用的图像很小并且工作正常。

    结果

    【讨论】:

      猜你喜欢
      • 2015-01-15
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      相关资源
      最近更新 更多