Defining custom attrs

前端 未结 5 1707
耶瑟儿~
耶瑟儿~ 2020-11-22 05:27

I need to implement my own attributes like in com.android.R.attr

Found nothing in official documentation so I need information about how to define these

5条回答
  •  名媛妹妹
    2020-11-22 06:04

    Qberticus's answer is good, but one useful detail is missing. If you are implementing these in a library replace:

    xmlns:whatever="http://schemas.android.com/apk/res/org.example.mypackage"
    

    with:

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

    Otherwise the application that uses the library will have runtime errors.

提交回复
热议问题