Android SrcollView嵌套recyclerView的使用
生活随笔
收集整理的這篇文章主要介紹了
Android SrcollView嵌套recyclerView的使用
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
今天,簡單講講Android里使用SrcollView嵌套recyclerView需要注意的地方。
?
不廢話了直接上代碼,在使用時加上下面的代碼就可以
recyclerView.setLayoutManager(new LinearLayoutManager(this){@Overridepublic boolean canScrollVertically() {//解決ScrollView里存在多個RecyclerView時滑動卡頓的問題//如果你的RecyclerView是水平滑動的話可以重寫canScrollHorizontally方法return false;} }); //解決數(shù)據(jù)加載不完的問題 recyclerView.setNestedScrollingEnabled(false); recyclerView.setHasFixedSize(true); //解決數(shù)據(jù)加載完成后, 沒有停留在頂部的問題 recyclerView.setFocusable(false);-
切記,切記,切記, 重要的事情說三遍, 還解決不了的時候看這里
關(guān)于嵌套后滑動卡頓或者焦點之類的問題
使用了上面的方法還無法解決就把布局中的RecyclerView外層的ScrollView換成NestedScrollView就可以解決了
?大概就改成這樣
<android.support.v4.widget.NestedScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><android.support.v7.widget.RecyclerViewandroid:layout_width="match_parent"android:layout_height="wrap_content" /><android.support.v7.widget.RecyclerViewandroid:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout> </android.support.v4.widget.NestedScrollView>?
Android SrcollView嵌套recyclerView的使用就講完了。
?
就這么簡單。
?
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的Android SrcollView嵌套recyclerView的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android Studio下载及安装3
- 下一篇: Android 设置TextView字体