set animation on listview scrolling in android

后端 未结 5 1454
温柔的废话
温柔的废话 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

    ListView Adapter:

    Animation scaleUp;
    
     public MyAdapter(...) {
               //...
         scaleUp = AnimationUtils.loadAnimation(activity, R.anim.scale_up_fast);
     }
    
     public View getView(final int position, View convertView, ViewGroup parent) {
    
        CardView cv;
    
        if (convertView == null){
          inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = inflater.inflate(R.layout.your_layout, parent, false);
        }
        cv = (CardView) convertView.findById(R.id.yourView);//Change this to your view      
        cv.startAnimation(scaleUp);
     }
    

    Animation:

    
    
    
        
    
    

提交回复
热议问题