Set Background as null

后端 未结 5 1728
时光取名叫无心
时光取名叫无心 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:14

    If background is not needed then there is no need to mention it in xml. At least it will be one less parsing of XML element.

    0 讨论(0)
  • 2021-02-13 04:17

    i think you are looking for this:

    android:background="@android:color/transparent"
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-13 04:30

    I think, because you dont need to find this view on code side, it will effect to performance positive. and i dont think that it is not safe.

    0 讨论(0)
  • 2021-02-13 04:38

    It can be used for a number of things. I specifically use it to remove that underline in my EditText's. It is safe to use but just be sure that you require it in your code.

    0 讨论(0)
提交回复
热议问题