Petro
Petro

Reputation: 3652

Animate View and keep visible after animation

I have two indicators, each need to be invisible to start. I want them to be visible after animating in, how do i do this? Right now they animate in then disappear, here is the code:

                indicator.setVisibility(View.INVISIBLE);
                indicator2.setVisibility(View.INVISIBLE);
                Animation fadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in_view);

                indicator.startAnimation(fadeInAnimation);
                indicator2.startAnimation(fadeInAnimation);

My xml is:

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="1500"
        android:repeatCount="0" />
</set>

Upvotes: 2

Views: 62

Answers (1)

Vic Vuci
Vic Vuci

Reputation: 7051

Try doing this: fadeInAnimation.setFillAfter(true)

or

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="1500"
        android:repeatCount="0"
        android:fillAfter="true"/>
</set>

Upvotes: 1

Related Questions