Android : Which namespace to choose when having own attributes?

on Wednesday, October 29, 2014


I declare some custom attributes in res/values/attrs.xml. Now I want to refer to them in both the res/values/styles.xml where they should get added to the app theme and a layout file (located in res/layout/) like I do with android attributes by ?android:attr/someAttribute.


Questions:



  1. Do I have to specify a namespace anywhere? Where? and even more important: Why / Why not?

  2. How does this effect the ?android:attr/someAttribute-like part? How has this to look? If there are multiple "looks": Why isn't there only one?

  3. Where is the difference between xmlns:custom="http://schemas.android.com/apk/res-auto" and xmlns:custom="http://schemas.android.com/apk/res/com.example.awesomeproject" (where com.example.awesomeproject is the package of the app also noted in the AndroidManifest.xml)?

  4. How do the answers to the above questions change, if I move the attrs.xml and the corresponding styles.xml into an Android Library Project wich is on the built path? and even more important: Why?


0 comments:

Post a Comment