简体   繁体   English

底部的卡片视图阴影比顶部厚得多

[英]Card View shadow much thicker at the bottom than at the top

I have an app that uses CardViews very extensively, pretty much for every UI element in each view.我有一个应用非常广泛地使用 CardViews,几乎用于每个视图中的每个 UI 元素。 I noticed that the shadow around each CardView is much thicker around views close to the bottom than it is around views closer to the top:我注意到每个 CardView 周围的阴影在靠近底部的视图周围比靠近顶部的视图周围要厚得多:

例子

Any idea why that is, and if there's a way to change that behavior?知道为什么会这样吗,是否有办法改变这种行为?

That is so because that is what Material Design was mean to represent.之所以如此,是因为这就是 Material Design 的意思。

CardView appears to be thick at the bottom as that represents the shadow which a real card will cast if the cardView was replaced by it. CardView 在底部看起来很厚,因为这表示如果 cardView 被替换为真实卡片将投射的阴影。

If you want to tweak this parameter, you'll need to adjust the android:elevation="2dp" attribute for the cardView.如果你想调整这个参数,你需要调整android:elevation="2dp"android:elevation="2dp"属性。

Setting it to 0dp will disable the shadow and increasing it will increase it.将其设置为0dp将禁用阴影并增加它会增加它。

If you want to have shadows all around the cardView, refer to this answer which explains how to achieve it.如果你想在 cardView 周围有阴影,请参考这个解释如何实现它的答案

It's a normal behavior of android:elevation这是android:elevation的正常行为

If you want to have the same thick for top and bottom, use own background.如果您希望顶部和底部具有相同的厚度,请使用自己的背景。

For example, you can use nine patch image.例如,您可以使用九个补丁图像。 Shadow generator: http://inloop.github.io/shadow4android/阴影生成器: http : //inloop.github.io/shadow4android/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM