优势与CardView的缺点 [英] Advantage and disadvantage of CardView

查看:2431
本文介绍了优势与CardView的缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 CardView 的优点和缺点,比阴影或标高等,什么是性能和外观的好处?什么是使用 CardView ,也可以使用其他布局的组合所做的一切。

What are the advantages and drawbacks of CardView, other than the shadow or elevation, what is the benefit in performance and looks? What is done using CardView can also be done using a combination of other layouts.

推荐答案

Cardview 的优势绝对是它的阴影和圆角的默认实现,在简单的话 Cardview 只是一个阴影的FrameLayout和圆角。你几乎可以做同样的东西在 Cardview ,您可以用的FrameLayout (如 Cardview 扩展的FrameLayout )。在 Cardview 的API> 21使用高程API来设置阴影,而下面的API 21它增加了灰色背景填充,以制造假阴影(只是类似于自定义实现你在谈论)。

Advantage of Cardview is definitely its default implementation of the shadow and the rounded corners, in simple words Cardview is just a FrameLayout with shadow and rounded corners. You can do almost the same stuff with a Cardview that you can do with a Framelayout(as Cardview extends FrameLayout). The Cardview for API>21 uses the elevation api to set the shadows whereas for below API 21 it adds a padding with grey background to create fake shadows(just similar to the custom implementation you were talking about).

Cardview 被设计为在其内部保存单个子视图,并会很难不重叠在彼此管理多个孩子的意见,因为没有支持的特性,例如为 layout_below layout_torightof 等。要解决这个问题,开发商采取的方法是添加另一个 RelativeLayout的 Cardview 内来管理孩子的看法,现在这将导致更多的资源消耗因嵌套布局。

Cardview is designed to hold a single child view within itself and would be very difficult to manage multiple child views without overlapping over each other as there is no support of property such as layout_below,layout_torightof etc.. to overcome this, the approach taken by developers would be to add another Relativelayout within the Cardview to manage the child views, now this would lead to more resource consumption due to nested layouts.

要处理复杂的布局,它建议使用自定义视图,只使用单个子视图使用 Cardview

To handle complex layouts its recommended to use the custom views and just to use a single child view use the Cardview.

要简单地把圆边和阴影的开销:
如果您考虑的FrameLayout作为一个蛋糕,然后抬高就像结冰和圆边是像樱桃摘心。其审美的结冰和浇头,但你必须摆脱额外的雄鹿队结冰和樱桃。

To simply put the overhead of the rounded edges and shadows: If you consider the Framelayout as a cake then the elevation is like the icing and rounded edges is like cherry topping. Its aesthetic with the icing and the topping but you have to shed additional bucks for the icing and cherry.

这篇关于优势与CardView的缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆