listening to scroll events horizontalscrollview android

后端 未结 5 521
星月不相逢
星月不相逢 2020-11-30 05:21

I am trying to listen to the event when the HorizontalScrollView is scrolled. Tried this but it does not print anything.

HorizontalScrollView he         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 05:51

    you can try this, i've tried so many ways, but none of them meet my needs, and then i tried to do it myself, and i succeed , and it seems good , it's smooth.

    
    
    
        
            
    
            
    
                
    
            
        
    
    
    
    

    public class WrapContentListView extends ListView{
    public WrapContentListView(Context context) {
        super(context);
    }
    
    public WrapContentListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    public WrapContentListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    
    
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
    }
    

提交回复
热议问题