因爲使用RecyclerView,導致一進界面,界面自動滾動到RecyclerView的第一個position的位置,所以我嵌套使用NestedScrollView,避免這個問題。
但是我處理完所有事了之後,發現NestedScrollView嵌套RecyclerView會導致item的滑動有些生硬,沒有了那種慣性。
解決辦法:
LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setSmoothScrollbarEnabled(true); layoutManager.setAutoMeasureEnabled(true);
recyclerViewId.setLayoutManager(layoutManager); recyclerViewId.setHasFixedSize(true); recyclerViewId.setNestedScrollingEnabled(false);
在你的recyclerview上加上這些配置,就可以讓recyclerView的滾動具有慣性。