fullMoon fullMoon - 1 month ago 10
Android Question

Android TextView fade in animation not working

Here is what in the animation xml :

android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="4500"


and here where I call it:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
setContentView(R.layout.prayerlayout);

txt = (TextView) findViewById(R.id.textView2);
txt.setText(getString(R.string.eighth));

//apply animation
fade1 = AnimationUtils.loadAnimation(this, R.anim.fade10);
txt.startAnimation(fade1);
}


The issue is that the text doesn't show up for the duration of the animation, then it appears suddenly. I didn't notice this problem in older versions of android. It was working fine, but with Lollipop or Jellybeans it doesn't work. Thanks for any help.

Answer

It turned out that my text was too long causing the fade-in animation not to work. I applied the animation on the scrollView instead, and it did the effect I wanted.

Comments