Set Background as null

后端 未结 5 1730
时光取名叫无心
时光取名叫无心 2021-02-13 03:36

If I use the following line in the xml layout:

android:background=\"@null\"
  1. Is it safe?
  2. Is effective from a performance point o
5条回答
  •  迷失自我
    2021-02-13 04:18

    1. android:background="@null" is absolutely safe. If you want to set the background based on your logic in code, you can definitely use this; and if you do not set the background in code, it is still the same and will never cause any problems.

    2. From a performance point of view, you should load the background via XML instead of programmatically because your layout will be loaded only once from the XML. If you set it in code based on your logic, it may be loaded more than once. However, in either case, the performance is almost the same, not a big difference. You should decide which approach to use from your logic point of view (if you will never change the background, use the XML approach). The point is, use the image of the appropriate size as the background. That will make the real difference in performance. Big images will take more time to load in either approach.

提交回复
热议问题