Android: ScrollView vs NestedScrollView

前端 未结 6 2500
太阳男子
太阳男子 2020-11-29 17:48

What is the difference between ScrollView and NestedScrollView? Both of them, extend FrameLayout. I want to know in depth pros and con

6条回答
  •  失恋的感觉
    2020-11-29 18:26

    NestedScrollView is just like ScrollView, but in NestedScrollView we can put other scrolling views as child of it, e.g. RecyclerView.

    But if we put RecyclerView inside NestedScrollView, RecyclerView's smooth scrolling is disturbed. So to bring back smooth scrolling there's trick:

    ViewCompat.setNestedScrollingEnabled(recyclerView, false);
    

    put above line after setting adapter for recyclerView.

提交回复
热议问题