CardView动态阴影不仅取决于仰角 [英] CardView dynamic shadow depends not only on elevation

查看:113
本文介绍了CardView动态阴影不仅取决于仰角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发我的应用程序时,我创建了一个内部带有可扩展CardViews的RecyclerView,然后提到嘿,为什么我只对卡片的垂直尺寸和扩展的不透明度设置动画时,海拔有所变化?" .

While developing my app I'd created a RecyclerView with expandable CardViews inside and then mentioned "hey, why does the elevation is changing a bit while I'm animating only vertical size of card and opacity of extension?".

然后我发现不是高程撞击了-只是阴影改变了.

And then I've found what it's not an elevation who chages -- it's only a shadow changed.

有人听说过吗?这只是界面图的一个未描述的东西吗?我对酷炫功能没有异议,但这让我有些困惑(我甚至已经花了大约一个小时的时间才能在Google指南中找到有关此功能的信息)

Does anybody heard smth about it? Is it just an undescribed thing of interface drawing? I have no objections for cool feature, but it just a bit confused me (I've even spend about an hour to find out something about it on Google's guidelines)

我已经分享了证明高度会影响阴影绘制"思想的代码,但是如果背后还有更多信息,则可以分享一些信息.

I've shared the code that proves the idea of "height affects shadow drawing" but share some information if theres' something more behind this.

推荐答案

在Material Design中,有2个光源:

In Material Design there are 2 light sources:

  • 键灯-屏幕上方(头顶)约45°的尖锐光源
  • 环境光-垂直于屏幕(头后)的柔和弱光源
  • key light - a sharp light source ~45° above the screen (over your head)
  • ambient light - softer and weaker light source perpendicular to the screen (behind your head)

按键灯的阴影占主导地位.

The shadow of the key light dominates.

此模型在Android UI中实现.现在,键光发出的光以与底部的元素不同的角度撞击屏幕顶部附近的元素,因此阴影也以不同的角度投射,就像在现实中一样-材质设计的意图.

This model is implemented in Android UI. Now, the light from the key light is hitting elements close to the top of the screen under a different angle than elements at the bottom, so the shadow is cast under a different angle accordingly, just as in reality - the intention behind Material Design.

实际上:元素越靠近底部,元素底边缘的阴影越强,顶部边缘的阴影越浅.

Practically: the closer the element to the bottom, the stronger the shadow at the element's bottom edge and lighter at the top edge.

请参见材料设计:环境:灯光和阴影:灯光

图片链接自: https://touchlab .co/2016-1-consistent-lighting-in-material-design/

这篇关于CardView动态阴影不仅取决于仰角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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