i am drawing a triangle with xml as follows:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/rightArrow">
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-40%"
android:pivotY="87%" >
<shape
android:shape="rectangle" >
<stroke android:color="@android:color/transparent" android:width="10dp"/>
<solid
android:color="#000000" />
</shape>
</rotate>
</item>
</layer-list>
now i need to set the color of this triangle on run time, so i did
LayerDrawable layers = (LayerDrawable) this.getActivity().getResources().getDrawable(R.drwable.customtriangle);
GradientDrawable shape = (GradientDrawable)(ldrawable.findDrawableByLayerId(R.id.layerItemRightArrow));
shape.setcolor(mycolor);
but i am facing rotatedrwable can not be casted to gradientdrawble at
GradientDrawable shape = (GradientDrawable)(ldrawable.findDrawableByLayerId(R.id.layerItemRightArrow));
i cant figure out how to procced...
Any help appreciated.
Thanx in advance
Call getDrawable()
on the RotateDrawable
to get at the Drawable
that is being rotated.