is there any diff @null Vs #00000000

后端 未结 4 1078
野性不改
野性不改 2021-01-07 20:06

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

in my layout I set android:background\"@color/transparent\" but its showing some other

4条回答
  •  一整个雨季
    2021-01-07 20:39

    @null means no background at all (View.getBackground() returns null).

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

    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.

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

提交回复
热议问题