difference in naming xml between res-auto and com.package.name - android

后端 未结 1 682
遇见更好的自我
遇见更好的自我 2021-02-09 14:01

I have seen custom xml with :



        
1条回答
  •  礼貌的吻别
    2021-02-09 14:43

    If we add a new custom view and its attributes inside our project, you add this at the beginning of your layout:

    xmlns:custom="http://schemas.android.com/apk/res/your_main_app_package
    

    If the new custom view is inside a library project linked to your project, you add this:

    xmlns:custom="http://schemas.android.com/apk/res-auto
    

    Note: This problem has been fixed in ADT revision 17+ . For any services or Activities, declare the namespace as follows:

    xmlns:custom="http://schemas.android.com/apk/res-auto"
    

    The suffix res-auto will be replaced at build time with the actual project package, so make sure you set up your attribute names to avoid collisions if at all possible.

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