0

I have 3 TextView components that represent 3 different bars. I have created a scale animation so the percentage in each bar will grow from bottom of the container to the height of the TextView (each text has different size according to the percentage). The problem is that I created only one ScaleAnimation object but it behave differently if I use different background to that TextView. This is my code of the animation object and the TextView:

ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, (float)1.0, Animation.RELATIVE_TO_SELF, (float)1.0);
scaleAnimation.setFillAfter(true);
scaleAnimation.setDuration(1000);

tvHomeTeamPercentage.startAnimation(scaleAnimation);
tvDrawPercentage.startAnimation(scaleAnimation);
tvAwayTeamPercentage.startAnimation(scaleAnimation);

It is important to mention that the there is no difference between the text views at all except their height and their background (which is 9patch in all cases).

Shalom Melamed
  • 299
  • 1
  • 4
  • 13

1 Answers1

0

What fixed my problem was changing the line:

ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, (float)1.0, Animation.RELATIVE_TO_SELF, (float)1.0);

to:

ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, (float)1.0, Animation.RELATIVE_TO_PARENT, (float)1.0);
Shalom Melamed
  • 299
  • 1
  • 4
  • 13