作者:燕歆波
导读:elevation属性对布局层次的影响!
现象
在相对布局中,添加了一个输入框和一张搜索的图标,看效果图:
可以发现,搜索图标并没有显示出来,好在今天脑子比较好使,我直接想法就是去改elvation属性,果然,发现了有意思的东西;
给ImageView添加elvation属性之后,发现并没有使图表显示出来,又想到可能是elevation的值太小???
于是我把ImageView的elevation的值改成8dp
然后再看效果:
搜索图标出来了,再次修改ImageView的elevation为6dp,和输入框一样,发现也是可以显示的;
总结
elevation有提高元素层级的能力,就像html的z-index一样,值相同代表相同层级,值不同,大的层级高,
搜索相关博客后,发现果然如此!