Spinner drop down animation

3.9k views Asked by At

Trying to implement an animation in the following link https://dribbble.com/shots/1753718-Chat-Screen-UX-UI-iOS-App. Attaching what we tried so far below. Not able to reproduce the animation exactly. Share your ideas on how to implement it.

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        View view = convertView;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = mInflater.inflate(R.layout.rowlayout, null);
            viewHolder.textView = (TextView) view.findViewById(R.id.textView);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.textView.setText(mItems.get(position));
        animate(view, position);
        return view;
    }


     private void animate(View target, int index){

        Animation animtopOut = AnimationUtils.loadAnimation(mContext, R.anim.slide_top_to_bottom);
        animtopOut.setStartOffset(index * 100);
        target.startAnimation(animtopOut);
  }

Attaching the animation resource file

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromYDelta="-100%" android:toYDelta="0"
        android:duration="100" />
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
        android:duration="500" />
</set>
1

There are 1 answers

0
Tang Ke On

In my opinion:

  1. You need disable spinner's popup window animation style.
  2. Apply the animation to every list item in dropdown list item

The UX demo seem to every item should rotate from -90 to 0 by x axis to appear, You can use ViewPropertyAnimator.rotationX(float value) or ViewPropertyAnimator.rotationXBy(float value) to change to rotation x of view, remember to set the pivot y to 0 first so that the animation can rotate from top of view