解决CardView在5.0以下留白的问题

CardView在5.0以下显示会有一点留白,有点类似TextView默认的padding,这个时候即使设置contentPadding属性也是没有用的。


解决办法

在用的地方做一层判断,如果当前系统是5.0以下,padding设为负值,把留白撑掉。

   if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
       holder.mCardView.setContentPadding(-10, -10, -10, -10);
   }


猜你喜欢

转载自blog.csdn.net/yechaoa/article/details/80914363