Monday, April 1, 2013

[android-developers] Declare namespace from jar lib

Hi all,

I am facing a difficulty regarding appt and custom xml namespaces, will appreciate any help on the matter.

I am creating a SDK as jar. It contains some custom views with custom parameters. I want to create a drop-in solution, where developers don't need to do anything other than dropping the jar in their libs folder. I cannot go with a real library project, it's a business requirement.

Everything actually works fine, and this is not my first android project, that ships as jar. But in this one, I need to have custom attributes for custom views. This means that aapt needs to be aware of the attribute set supported by the views trough an xml schema.

The easy solution is to have the users put a predefined attr.xml in they resources folder and reference it in the layout. However I have seen that libraries like admob work without the custom attr.xml. For example by admob you declare:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

but developers don't need to add an attr.xml in their application. With this declaration only, it is sufficient  to use "ads:XXX=XXX" in the view.

I have already already looked into admobs jar file, and i cannot find anything special in the com.google.ads package, that looks like an xml namespace definition. Any idea how they managed to do this / where aapt gets the definition?

Thanks!


--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment