Android 和为(图像)视图 alpha 设置 alpha [英] Android and setting alpha for (image) view alpha

查看:29
本文介绍了Android 和为(图像)视图 alpha 设置 alpha的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否真的没有与 setAlpha(int) 对应的 XML 属性?

Is there really no XML attribute counterpart to setAlpha(int)?

如果没有,有什么替代方案?

If not, what alternatives are there?

推荐答案

不,没有,看看 ImageView.setAlpha(int) 文档.另一种方法是使用 View.setAlpha(float)XML 对应物android:阿尔法.它的范围是 0.0 到 1.0 而不是 0 到 255.使用它,例如喜欢

No, there is not, see how the "Related XML Attributes" section is missing in the ImageView.setAlpha(int) documentation. The alternative is to use View.setAlpha(float) whose XML counterpart is android:alpha. It takes a range of 0.0 to 1.0 instead of 0 to 255. Use it e.g. like

<ImageView android:alpha="0.4">

但是,后者仅在 API 级别 11 后可用.

However, the latter in available only since API level 11.

这篇关于Android 和为(图像)视图 alpha 设置 alpha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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