I've got a question on custom view XML-declarations.
I created my own View with the custom attributes as normal. Now I want to add more complex attributes like this: (This is non-working code)
<com.xxx.yyy.CustomTextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/customTextView1" android:layout_marginBottom="22dp" android:layout_toRightOf="@+id/buttonBlack" android:text="TextView" > <Animation animation:property1="123" animation:property2="456" /> <Animation animation:property1="789" animation:property2="012" > </Animation> </com.xxx.yyy.CustomTextView> I didnt find a way to do this on my own but maybe someone has got an idea.
Thanks!
Edit:
I just solved the problem more or less nicely. I created a new .xml file in my /res/xml folder called animations.xml
<animations> <animation name="Animation name 1" float1="1.1" float2="1.2" integer1="11" integer2="12" /> <animation name="Animation name 2" float1="2.1" float2="2.2" integer1="21" integer2="22" /> </animations> My custom view in attrs.xml contains an attribute which is used to reference the animations.xml file from above:
<declare-styleable name="MyTextView"> <attr name="animations" format="reference" /> </declare-styleable> Now i parse the referenced .xml file in the constructor of the MyTextView as described here: http://thedevelopersinfo.com/2009/12/14/using-xml-file-resources-in-android/
Maybe this helps somebody at some time.