How do you animate the background of a TextView that has been defined in xml?



For example I have the following as the background of a TextView:


<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://ift.tt/nIICcg" android:shape="oval" android:id="@+id/pulsator"> <stroke android:width="4dp" android:color="#77FF00" /> <corners android:topLeftRadius="10dp" android:topRightRadius="10dp" android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" /> <size android:height="8dp" android:width="8dp"/> </shape>


In the main activity I have:



txtMessageData = (TextView) findViewById(R.id.txtMessageData);


The background is set in xml as:



<TextView
.
.
android:background="@drawable/pulsator />


Animating the TextView itself is easy but I actually only want to animate the background. Essentially I'm aiming to have rings pulsating concentrically away from the TextView too show that it is actively updating.


I would think maybe a property animation could be used but I have not found a way to do it.


I have the following animation set defined in xml:



<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://ift.tt/nIICcg">
<alpha
android:duration="1500"
android:fromAlpha="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="0.0"
/>

<scale
android:duration="1500"
android:fromXScale="1.0"
android:toXScale="2.5"
android:fromYScale="1.0"
android:toYScale="2.5"
/>
</set>


Can this animation data be applied to the background of my TextView?


No comments:

Post a Comment