Android5.x中的阴影效果elevation和translationZ的实现方法
时间:2021-05-06 09:41:27|栏目:Android代码|点击: 次
android5.x中 view多了一个 属性 z,垂直高度上的变化。
Z属性 由两部分组成,elevation 和 translationZ
<ImageView android:id="@+id/me_daijjBack" android:layout_width="27dp" android:layout_height="27dp" android:elevation="3dp" android:translationZ="5dp" android:src="@drawable/shape_back" />
两者关系
Z=elevation 和 translationZ都 可以在 xml和代码中实现
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
btn.setElevation(3f);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
btn.setTranslationZ(5f);
}
上一篇:VS Code开发React-Native及Flutter 开启无线局域网安卓真机调试问题
栏 目:Android代码
本文标题:Android5.x中的阴影效果elevation和translationZ的实现方法
本文地址:http://www.codeinn.net/misctech/115886.html






