Android的CardView填充和了minHeight [英] Android CardView padding and minHeight
问题描述
今天,我在我的项目的更新支持的依赖,我发现了一些问题,用新的 CardView
。
Today I updated support dependencies in my project and I found some issues with the new CardView
.
previous版本:
Previous version:
compile 'com.android.support:cardview-v7:21.0.0-rc1@aar'
当前版本:
compile 'com.android.support:cardview-v7:21.0.0@aar'
所有它看起来像 minHeight的第一
不起作用了。解决的办法之一就是把任何的ViewGroup
卡内,并设置最低高度,但它看起来像一个bug给我。
First of all it looks like minHeight
doesn't work any more. One of the solutions is to put any ViewGroup
inside the card and set the minimum height, but it looks like a bug for me.
对于我的第二个问题是垫。随着新版本的库垫都较大。如果你把一些卡片相邻他们之间的差距实在是太大了较大。我已经尝试设置填充,以 0dp
但它看起来像填充来自 9.png
文件。下面粘贴的code不会改变任何东西。
The second issue for me are paddings. With the new library release paddings are larger. If you put some cards next to each other the gap between them is way to large. I've tried setting the padding to 0dp
but it looks like the padding comes from 9.png
file. The code pasted below doesn't change anything.
<android.support.v7.widget.CardView
android:padding="0dp"
...
我也试过用负值也没什么。有什么办法来解决pre-棒棒糖设备这两个问题?
I've also tried with negative values but also nothing. Is there any way to solve this two issues for pre-Lollipop devices?
推荐答案
关于你这里有新的信息填充的东西:<一href=\"http://developer.android.com/reference/android/support/v7/widget/CardView.html\">http://developer.android.com/reference/android/support/v7/widget/CardView.html
About the padding stuff you have new information here: http://developer.android.com/reference/android/support/v7/widget/CardView.html
前l,CardView添加填充其内容,并绘制阴影
该区域。这个填充量等于maxCardElevation 1 +(1 -
cos45)* cornerRadius侧面和maxCardElevation * 1.5 +(1 -
cos45)*顶部和底部cornerRadius。
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.
由于使用填充,以抵消阴影的内容,你可以不设置
填充上CardView。相反,你可以使用内容填充属性
在code XML或setContentPadding(INT,INT,INT,INT)设定
该卡CardView的边缘和孩子之间的填充。
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!