NestedScrollView+RecyclerView 滑動卡頓簡單解決方案
今天遇到一個問題,就是那個使用NestedScrollView+RecyclerView會卡頓,這樣滑動起來會卡頓,給使用者帶來了很不好的體驗,也是想著去解決一下。於是我上了百度,哈哈,別我找到了解決方案,我記錄一下,也供大家參考一下。
在給RecyclerView設定layoutManager 的時候設定幾個引數,我附上原始碼的解釋,引數的意思我也大概的翻譯一下,意思差不多,方便大家理解
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
/**
* When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed
* based on the number of visible pixels in the visible items. This however assumes that all
* list items have similar or equal widths or heights (depending on list orientation).
* If you use a list in which items have different dimensions, the scrollbar will change
* appearance as the user scrolls through the list. To avoid this issue, you need to disable
* this property.
*/
//啟用平滑滾動條
layoutManager.setSmoothScrollbarEnabled(true);
/**Defines whether the layout should be measured by the RecyclerView or the LayoutManager
* wants to handle the layout measurements itself.
*/
//自動測量
layoutManager.setAutoMeasureEnabled(true);
recyclerView.setLayoutManager(layoutManager);
//@param hasFixedSize true if adapter changes cannot affect the size of the RecyclerView.
recyclerView.setHasFixedSize(true);
//巢狀設定為不可滑動
recycerView.setNestedScrollingEnabled(false);
ok,到此就結束了
相關文章
- Android 介面滑動卡頓分析與解決方案(入門)Android
- vue 介面在蘋果手機上滑動點選事件等卡頓解決方案Vue蘋果事件
- 解決ScrollView巢狀RecyclerView滑動卡頓問題View巢狀
- 不要在 XML 設定,解決 NestedScrollView 巢狀 RecyclerView 滑動卡頓XMLView巢狀
- 使用NVRAM的簡單解決方案VR
- 一種巢狀滑動衝突的解決方案巢狀
- 巢狀UIScrollview的滑動衝突解決方案巢狀UIView
- 移動端swiper嵌iframe無法滑動的解決方案
- 如何解決快應用頁面滑動卡頓問題
- 簡單的mock-server 解決方案MockServer
- 一種非巢狀滑動衝突的解決方案巢狀
- 簡單的瞭解跨域以及解決方案跨域
- vant小程式SwipeCell 完美解決滑動單元格右滑無樣式
- 用ListView簡單實現滑動列表View
- 聊天平臺原始碼,簡單使用 禁止滑動和設定滑動方向原始碼
- ViewPager 禁止左右滑動完美解決Viewpager
- 滑動動效解決方案(CSS antd-mobile better-scroll react-transition-group)CSSReact
- UIPikerView 省市區三聯滑動,解決滑動崩潰問題UIView
- 移動APP卡頓問題解決實踐APP
- 蘋果容器超出內容overflow滑動卡頓問題蘋果
- win10執行老遊戲卡頓怎麼解決 win10執行老遊戲頻繁卡頓解決方案Win10遊戲
- jquery 實現滑動條的簡單驗證jQuery
- div拖動遇到iframe卡頓的問題解決
- 阿里雲滑塊驗證失敗解決方案阿里
- 簡單監測iOS卡頓的demoiOS
- 直播系統中影片出現卡頓的原因及解決方案
- ScrollView 與ListView 滑動衝突解決View
- 一個簡單的統計問題(解決方案:Trie樹)
- 簡單介紹Nginx tp3.2.3 404問題解決方案Nginx
- 圖片即時優化的三種簡單解決方案優化
- 塗鴉框架的優化——解決繪製時的卡頓問題,縱享絲滑框架優化
- html裡列表滑動刪除的實現如此簡單HTML
- (轉)解決XMind執行卡頓
- ScrollView(RecyclerView等)為什麼會自動滾動原理分析,還有阻止自動滑動的解決方案View
- CSS3 動畫卡頓效能優化解決方案CSSS3動畫優化
- CSS3動畫卡頓效能優化解決方案CSSS3動畫優化
- 超簡單的前端跨域、前後端分離解決方案前端跨域後端
- 關於iScroll外掛在某一些手機上滑動卡頓或者不滑動的處理