是否有可能使用CardView使阴影浮动操作按钮? [英] Is it possible to use CardView to make shadow for Floating Action Button?

查看:446
本文介绍了是否有可能使用CardView使阴影浮动操作按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 CardView 未对本作,但在理论上,如果 cardCornerRadius = view_size / 2 这应导致在圈。

I know CardView is not made for this, but in theory if cardCornerRadius = view_size / 2 it should result in circle.

我缺少的东西吗?

推荐答案

真正的绘画,动画的阴影并不难,你可以尝试实现棒棒堂对任何Android的影响降到升级Froyo。下面是它如何工作的:

Drawing real, animated shadows is not that difficult and you can try to achieve Lollipop's effect on any Android down to Froyo. Here's how it works:


  1. 把你的意图使用LightingColorFilter屏幕外的位图(0,0)

  2. 位图使用ScriptIntrisincBlur模糊。模糊半径设置为您的高程值。

  3. 画出模糊的位图的浮动操作按钮的下方。

这是基本的Andr​​oid 5.0使用绘制其阴影的方法。举一个例子实现见:

This is basically the method Android 5.0 uses for drawing its shadows. For an example implementation see:


  • 阴影生成,模糊的观点:<一href=\"https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/shadow/ShadowGenerator.java\" rel=\"nofollow\">https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/shadow/ShadowGenerator.java

  • 的LinearLayout与阴影的支持,检查drawChild()方法:<一href=\"https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/widget/LinearLayout.java#L102\" rel=\"nofollow\">https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/widget/LinearLayout.java#L102

基本上碳库试图模仿棒棒堂的效果尽可能的好。我知道,这样的导入库可能是矫枉过正,但如果你愿意,你可以只复制code的有趣的部分,并在你的应用程序中使用它。

Basically Carbon library tries to mimic Lollipop's effect as good as possible. I'm aware of that importing such library might be an overkill, but if you wish you can copy only the interesting part of code and use it in your app.

这篇关于是否有可能使用CardView使阴影浮动操作按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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