set animation on listview scrolling in android

后端 未结 5 1444
温柔的废话
温柔的废话 2021-01-01 08:20

I want to set an animation for a ListView for when a user scrolls the ListView. I am setting an animation for ListView when loading, b

5条回答
  •  耶瑟儿~
    2021-01-01 08:38

    Simple and fabulous animation on listview scrolling

     @Override`
    public View getView(final int i, View view, ViewGroup viewGroup) {
        View converview = view;`
    // other coding related to view
    
        if (animateOrNot) {    //boolean if want to animate
            doCards(converview, i, prevPos);}
           `prevPos=i; //take prevPos as global variable of int
        return converview;
    }`
    
    
    
        public static void doCards(View view, int position, int prevPosition) {
        view.setScaleX(0.5f);
        if (position > prevPosition) {
            view.setRotationX(90);
        } else {
            view.setRotationX(-90);
        }
        view.animate().rotationX(0).scaleX(1.0f).start();
    }
    

提交回复
热议问题