I am running a top to down animation every time I update my listview, however, when I do this, the listview flashes white before it animates... is there any way I am able to fix this
Here is the method where I call the animation:
public void updateDataList(ArrayList<HashMap<String, String>> newList){
final ArrayList<HashMap<String, String>> newListAdd = newList;
Animation anim = AnimationUtils.loadAnimation(
liveStreamFragment.getActivity(), R.anim.top_to_down
);
anim.setDuration(2000);
list.startAnimation(anim);
new Handler().postDelayed(new Runnable() {
public void run() {
oslist.clear();
oslist.addAll(newListAdd);
LiveAdapter.this.notifyDataSetChanged();
}
}, anim.getDuration());
}
And here is my xml for R.anim.top_to_down
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="20%p" android:toYDelta="-20"
android:duration="@android:integer/config_mediumAnimTime"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_mediumAnimTime" />
It looks to me like it's an issue with the animation.
android:fromAlpha="0.0"
means that the item will start the animation with an alpha value of 0.0, meaning it will be completely transparent.android:toAlpha="1.0"
then specifies that the item should animate towards an alpha value of 1.0, a.k.a. completely opaque.If you want the item to fade out, which is typical for exit animations, you would want to switch the values.