I have an outer clip drawable (clip_drawable.xml) which embeds another transition drawable (transition_drawable.xml), which itself refers to 2 shape drawables.
clip_drawable.xml:
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="vertical"
android:drawable="@drawable/transition_drawable"
android:gravity="top" >
</clip>
transition_drawable.xml:
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="oval" >
<stroke
android:width="3dp"
android:color="@color/titan" />
<gradient
android:angle="270"
android:centerColor="@android:color/transparent"
android:centerY="0.4"
android:startColor="@color/titan" />
<padding
android:bottom="10dp"
android:left="15dp"
android:right="15dp"
android:top="10dp" />
</shape>
</item>
<item>
<shape android:shape="oval" >
<stroke
android:width="3dp"
android:color="@color/titan" />
<gradient
android:angle="270"
android:centerColor="@android:color/transparent"
android:centerY="0.1"
android:startColor="@color/titan" />
<padding
android:bottom="10dp"
android:left="15dp"
android:right="15dp"
android:top="10dp" />
</shape>
</item>
</transition>
I want to use this compound drawable as a button background:
<Button
android:id="@+id/continue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/clip_drawable"
android:text="@string/label_continue"
android:textColor="@android:color/white"
android:textSize="20sp" />
In the code I can refer to the ClipDrawable and set a level by saying:
final ClipDrawable clipDrawable = (ClipDrawable) button.getBackground();
clipDrawable.setLevel(3000);
But how can I get a reference to the transition drawable, in order to start the transition? It is not the solution to just write, this won't work of course:
final TransitionDrawable transitionDrawable = (TransitionDrawable) this.getResources()
.getDrawable(R.drawable.transition_drawable);
transitionDrawable .startTransition(1000);