今天我更新了项目中的支持依赖项,发现新的 CardView
存在一些问题。
以前的版本:
compile 'com.android.support:cardview-v7:21.0.0-rc1@aar'
当前版本:
compile 'com.android.support:cardview-v7:21.0.0@aar'
首先看起来 minHeight
不再起作用了。解决方案之一是将任何 ViewGroup
放入卡片中并设置最小高度,但对我来说这看起来像是一个错误。
对我来说,第二个问题是填充。随着新库的发布,填充更大。如果你把一些卡片放在一起,它们之间的差距就会很大。我试过将填充设置为 0dp
但看起来填充来自 9.png
文件。下面粘贴的代码不会改变任何内容。
<android.support.v7.widget.CardView
android:padding="0dp"
...
我也尝试过负值,但也没有。对于 Lollipop 之前的设备,有什么办法可以解决这两个问题吗?
最佳答案
关于填充内容,您在这里有新信息:http://developer.android.com/reference/android/support/v7/widget/CardView.html
Before L, CardView adds padding to its content and draws shadows to that area. This padding amount is equal to maxCardElevation + (1 - cos45) * cornerRadius on the sides and maxCardElevation * 1.5 + (1 - cos45) * cornerRadius on top and bottom.
Since padding is used to offset content for shadows, you cannot set padding on CardView. Instead, you can use content padding attributes in XML or setContentPadding(int, int, int, int) in code to set the padding between the edges of the Card and children of CardView.
关于Android CardView 填充和 minHeight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26439988/