是否有任何差异@null Vs#00000000 [英] is there any diff @null Vs #00000000

查看:117
本文介绍了是否有任何差异@null Vs#00000000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@null与透明(#00000000)之间是否有区别

Is there any difference between @null Vs transparent(#00000000)

在我的布局中,我设置了 android:background"@ color/transparent" 但是它显示了我使用的其他不同背景色.

in my layout I set android:background"@color/transparent" but its showing some other different background color that I used.

当我使用null可以正常工作时.

when I used null its working fine.

我想通过编程方式设置@null.

I want to set @null thru programmatic.

怎么办?

推荐答案

@null 表示根本没有背景(View.getBackground()返回null).

#00000000 表示您有一个ColorDrawable作为背景,具有完全透明的颜色.

#00000000 means that you got a ColorDrawable as the background which has a fully-transparent color.

我没有看代码,但是我猜想框架会测试ColorDrawable是否完全透明,并且在这种情况下不会绘制它.否则,您将需要一些绘图开销,从而使 @null 成为更快的选择.两者看起来应该相同,所以不确定这是否是您的潜在问题.

I didn't look at the code, but I guess that the framework tests if the ColorDrawable is fully transparent and does not draw it in this case. Otherwise you would have some drawing overhead, making @null the faster choice. Both should look identical, so not sure if this is your underlying isse.

要在代码中设置 @null 的等效项,请使用

To set the equivalent of @null in code, use View.setBackgroundDrawable(null).

这篇关于是否有任何差异@null Vs#00000000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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