Prevent CollapsingToolbarLayout collapse if not needed

前端 未结 6 1932
情歌与酒
情歌与酒 2020-12-05 02:30

Using:

compile \'com.android.support:design:23.0.0\'
compile \'com.android.support:appcompat-v7:23.0.0\'
compile \'com.android.support:cardview-v7:23.0.0\'
c         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 03:13

    To implement such behaviour in Cheesesquare example just modify android:layout_height param of the NestedScrollView to wrap_content. It will prevent scrolling by content if it is small enough to fit on the screen.

    And to prevent scrolling by CollapsingToolbarLayout you should programmatically set layout_scrollFlags parameter to the AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP value.

    Here described how you can do this.

提交回复
热议问题