CollapsingToolbarLayout doesn't recognize scroll fling

后端 未结 6 975
野趣味
野趣味 2020-12-02 07:08

I have created a simple CollapsingToolbarLayout and it works like a charm. My problem is, that if I try to use a fling scroll on the nestedscrollvie

6条回答
  •  悲哀的现实
    2020-12-02 07:57

    I had exactly the same issue with CollapsingToolbarLayout with ImageView inside and NestedScrollView. The fling scroll stops when finger is released.

    However, I've noticed something strange. If you start scrolling with your finger from a view with OnClickListener (e.g. Button), the fling scrolling works perfectly.

    Thus I fixed it with a weird solution. Set OnClickListener (that does nothing) on the direct child of NestedScrollView. Then it works perfectly!

    
    
      
    
        
    
      
    
    
    

    Give the direct child (LinearLayout) an id and set OnClickListener in Activity

    ViewGroup mContentContainer = (ViewGroup) findViewById(R.id.content_container);    
    mContentContainer.setOnClickListener(this);
    
    @Override
    public void onClick(View view) {
        int viewId = view.getId();
    }
    

    Notes:

    Tested using Support Design Library 25.0.1

    CollapsingToolbarLayout with scrollFlags="scroll|enterAlwaysCollapsed"

提交回复
热议问题