Android AppCompat 21 Elevation [英] Android AppCompat 21 Elevation

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

问题描述

有没有什么方法可以在不将它们包装在 CardView 中的情况下,在 pre-lollipop 设备中为 View 添加高度?

解决方案

ViewCompat.setElevation(View, int) 当前不创建垫片.

现在模拟高程的唯一方法是应用 v21 之前的阴影.在 values 中定义您的样式/布局/drawable,并在 values-v21 中覆盖它.对于按钮,我使用样式覆盖.对于布局,我通常会使用引用覆盖(使用 @null 摆脱可绘制对象).

希望将来对支持库的更新能够添加垫片.

这个 reddit 线程会跟踪上述更新.>

编辑

新的支持设计库 实际上确实为浮动操作按钮创建了垫片.

Is there any way to add elevation to a View in pre-lollipop devices without wrapping them in a CardView?

解决方案

ViewCompat.setElevation(View, int) currently creates no shims.

The only way to simulate elevation right now is to apply a shadow pre-v21. Define your style/layout/drawable in values and override it in values-v21. For buttons I use style overrides. For layouts, I usually go for reference override (use @null to get rid of a drawable).

Hopefully in the future an update to the support library will add shims.

This reddit thread keeps track of said update.

Edit

The new support design library actually does create shims for the floating action button.

这篇关于Android AppCompat 21 Elevation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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