I can't seem to figure out this one. I'm working on an android project where I have created a tween animation that scales the TextView a number of times. My animation resource is defined as follows...
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="1" android:fromYScale="1"
android:toXScale="2" android:toYScale="2"
android:pivotX="50%" android:pivotY="50%"
android:duration="500"
android:startOffset="0"/>
<scale android:fromXScale="2" android:fromYScale="2"
android:toXScale="1" android:toYScale="1"
android:pivotX="50%" android:pivotY="50%"
android:duration="500"
android:startOffset="500"/>
<scale android:fromXScale="1" android:fromYScale="1"
android:toXScale="2" android:toYScale="2"
android:pivotX="50%" android:pivotY="50%"
android:duration="500"
android:startOffset="1000"/>
<scale android:fromXScale="2" android:fromYScale="2"
android:toXScale="1" android:toYScale="1"
android:pivotX="50%" android:pivotY="50%"
android:duration="500"
android:startOffset="1500"/>
</set>
The TextView to which the animation is applied is defined in an xml layout resource file inside a RelativeLayout as follows...
<TextView
android:id="@+id/textView1"
android:text="@string/textView1Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color"
android:shadowColor="@color/text_shadow_color"
android:shadowDx="0.0"
android:shadowDy="0.0"
android:shadowRadius="20.0"
android:textSize="@dimen/text_size_large"
android:layout_centerInParent="true"/>
Then, the animation is initialized and loaded from an activity...
animation1 = AnimationUtils.loadAnimation(this, R.anim.textview_grow_shrink);
textView1.startAnimation(growShrinkAnimation);
I think the code explains the intention which is scaling the TextView from big to small and viceversa
The problem
While the animation does start and runs as intended it seems that scaling is out of proportion while the animation is running. The TextView seems to grow way too big out of the screen boundaries until the animation stops and the TextView goes back to its initial state.
I have no idea if the initial size of the text has anything to do with this weird behaviour. The textSize property is set to 36sp through a value resource (text_size_large) set in the dimens resource file
Question
Has anybody had this problem before? Is it something obvious I'm missing? How can I get this to work as expected?
I've tried Googling using several keywords but the articles that popped up where slightly unrelated. Cheers