0

I am running an animation within my listview, and I wondering how I am able to set the xml attribute, yDelta, within my java class. It is contingent upon the size of the current row, so I can't use a single value. Here is my animation code

<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="1.0" android:toAlpha="1.0"
    android:duration="@android:integer/config_mediumAnimTime" />

here is my java code

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());

}

1 Answers1

0

Accordingly to this documentation you can set it in constructor:

TranslateAnimation translate = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);

Also check this similar question.

Vijay
  • 575
  • 4
  • 14
Anton Kovalyov
  • 932
  • 4
  • 13
  • 1
    Please provide more information than just a snippet of code, i.e. explaining your answer, why your answer is the correct answer, maybe a link to some documentation, etc. – Akos Krivachy Jun 10 '15 at 00:03