I have used this line too add image in my textView : android:drawableLeft="@drawable/ic_launcher"
in my xml file.
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:text="@string/hello_world"
android:textSize="14sp"
android:textStyle="bold"
android:drawableLeft="@drawable/ic_launcher"
>
</TextView>
Now I want to add animation to this drawable. I dont know how can I access this image.
Any help? thanks in advance
To make simple animations like rotation you can do something like this:
Assume
@drawable/ic_launcher
is a drawable you want to animate.Define
some_drawable.xml
with the appropriate values:Assign this drawable as a compound one to your TextView:
To start animation:
if you set the drawable in the XML, you won't be able to access it like you can with an
ImageView
'sgetDrawable()
. Instead, omit it from your XML and do it in yourActivity/Fragment
:Provided your drawable
ic_launcher
can be animated like an AnimationDrawable, this should start the animation. Calld.stop()
to cease animation.