Reputation: 9226
I'm creating an animation to increase the size of TextView. this is my XML:
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.5"
android:toXScale="2.5"
android:fromYScale="0.5"
android:toYScale="2.5"
android:duration="4000" />
and this is my Java file:
Animation anim = AnimationUtils.loadAnimation(MainActivity.this, R.anim.answeranim);
txtanswer.startAnimation(anim);
My problem is that my TextViewer goes to the screen center and starts the animation. I want my TextViewer to increase his size from position that I set already. In fact I want the Animation to just increase the TextViewer size not change it's position. How can I do this?
Upvotes: 0
Views: 220
Reputation: 1210
I think that this may give you some directions, you probably will have to tweak the valeus a bit:
TextView text = (TextView) this.findViewById(R.id.idTesteText);
ScaleAnimation anim = new ScaleAnimation(1.0f, 2.0f, 1.0f, 2.0f,
Animation.RELATIVE_TO_SELF,1.0f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setDuration(700);
text.startAnimation(anim);
If you set pivotX and pivotY half of the width and height it will scale from center if you need that.
You can check de documentation here: http://developer.android.com/reference/android/view/animation/ScaleAnimation.html
Upvotes: 2