RecycleView彈性滑動

還有點bug,建議使用?LinearSnapHelper

  rvPilotList.addOnScrollListener(new RecyclerView.OnScrollListener() {@Overridepublic void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {super.onScrolled(recyclerView, dx, dy);//                offsetY += dy;
//
//                int first = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
//                int last = linearLayoutManager.findLastCompletelyVisibleItemPosition();
//                View firstview = linearLayoutManager.findViewByPosition(first);
//                if (viewWidth == 0) {
//                    viewWidth = firstview.getHeight();
//                }
//                int offseta = firstview.getTop();
//                float sx = 1f + (float) offseta / viewWidth;
//                if (offsetY == 0) {
//                    View view = linearLayoutManager.findViewByPosition(first + 1);
//                    scaleUp(view);
//                }
//
//                firstview.setScaleX(sx);
//                View lastview = linearLayoutManager.findViewByPosition(last);
//                offseta = recyclerView.getHeight() - lastview.getBottom();
//                sx = 1f + (float) offseta / viewWidth;
//                lastview.setScaleX(sx);}@Overridepublic void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {super.onScrollStateChanged(recyclerView, newState);if (newState == 0) {int visibleItem = linearLayoutManager.getChildCount();int coun = 0;if (visibleItem % 2 == 1) {coun = (visibleItem - 1) / 2;} else {coun = visibleItem / 2;}Log.i(TAG, "onScrollStateChanged: " + visibleItem);Log.i(TAG, "onScrollStateChanged: coun" + coun);int postion = linearLayoutManager.findFirstVisibleItemPosition();Log.i(TAG, "onScrollStateChanged: postion" + postion);View view;Log.i(TAG, "findFirstCompletelyVisibleItemPosition: " + linearLayoutManager.findFirstCompletelyVisibleItemPosition());if (postion == 0 && linearLayoutManager.findFirstCompletelyVisibleItemPosition() != 0) {view = linearLayoutManager.findViewByPosition(0);} else {view = linearLayoutManager.findViewByPosition(postion + coun);}int pm = ((ViewGroup) view.getParent()).getMeasuredWidth();int left = view.getLeft() + view.getWidth() / 2;int offset = 0;if (left == pm / 2) {return;}if (left < pm / 2) {offset = -(pm / 2 - left);} else {offset = left - pm / 2;}rvPilotList.smoothScrollBy(offset, 0);}}});

  

轉載于:https://www.cnblogs.com/6324/p/10733971.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/277895.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/277895.shtml
英文地址,請注明出處:http://en.pswp.cn/news/277895.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

關于深度學習,這些知識點你需要了解一下

深度學習概述 o 受限玻爾茲曼機和深度信念網絡 o Dropout o 處理不平衡的技巧 o SMOTE&#xff1a;合成少數過采樣技術 o 神經網絡中對成本敏感的學習 深度學習概述 在2006年之前&#xff0c;訓練深度監督前饋神經網絡總是失敗的&#xff0c;其主要原因都是導致…

發送不同類型的ActivityFeed

上一篇文章講到了如何使用最新的Graph API來給一個用戶發送一個簡單的 Activity Feed。我們這篇文章來詳細講一下發送三種不同類型的消息。 發送 Chat 相關的 Activity Notification API 為 POST https://graph.microsoft.com/beta/chats/{chat-id}/sendActivityNotification…

git add * 提示warning: LF will be replaced by CRLF in 解決辦法

在使用git的時候&#xff0c;每次執行 $ git add * 都會提示這樣一個警告消息&#xff1a; 雖然說沒有什么影響吧。 不過就是覺得太礙眼了&#xff0c; 按照這樣設置就沒有問題了: git config core.autocrlf false 這樣設置git的配置后在執行add操作就沒有問題了。 奮斗的年紀你…

git 放棄本地修改,強制拉取更新

開發時&#xff0c;對于本地的項目中修改不做保存操作&#xff08;或代碼改崩&#xff09;&#xff0c;可以用到Git pull的強制覆蓋&#xff0c;具體代碼如下&#xff1a; git fetch --all git reset --hard origin/master git pull //可以省略 git fetch 指令是下載遠程倉庫最…

發送ActivityFeed的隱藏功能

前兩篇文章介紹了如何發送 activity notification&#xff0c;這篇文章主要介紹兩個隱藏功能&#xff0c;實際上所謂的隱藏功能是指大家在閱讀官方文檔是會忽略的兩個點&#xff0c;但是實際上也是很實用的兩個功能點。 text 類型的 topic 之前文章中提到我們的 activity not…

Dispatch Queue 之 Invoke 當前隊列

&#xfffc; 轉載于:https://www.cnblogs.com/huahuahu/p/dispatch-queue-zhi-invoke-dang-qian-dui-lie.html

js或jQuery獲取當前屏幕的各種高度

Javascript: 網頁可見區域寬&#xff1a; document.body.clientWidth 網頁可見區域高&#xff1a; document.body.clientHeight 網頁可見區域寬&#xff1a; document.body.offsetWidth (包括邊線的寬) 網頁可見區域高&#xff1a; document.body.offsetHeight (包括邊線的高) …

Teams數據統計 - 用戶在線離線狀態

前幾天我在wechat的moments里看到以為朋友發了騰迅會議的對用戶個人的年度數據統計&#xff0c;看上去很有大數據感。 實際上 Teams 也具備的類似的能力&#xff0c;只是它把這個能力開放給了開發人員&#xff0c;我們可以通過強大的 Graph API&#xff0c;獲取大量的數據信息&…

我們是如何通過全球第一免費開源ERP Odoo做到項目100%交付

傳統友商ERP的交付過程 一、先初步需求調研&#xff0c;后選型功能模塊 傳統友商ERP第一件事情先對客戶方進行初步的調研&#xff0c;客戶方無論說什么&#xff0c;友商聽過算過&#xff0c;只關心你人數多少&#xff0c;有哪些人涉及到哪些模塊&#xff0c;接著對模塊進行所謂…

HDU 4747 Mex

4747 思路&#xff1a; 線段樹 先求出mex(1,1)&#xff0c; mex(1, 2) &#xff0c; mex(1,3)&#xff0c;...&#xff0c;mex(1&#xff0c;n)&#xff08;單調上升&#xff09;&#xff0c;先將這些mex放進線段樹里求和 然后再求出next[i]表示下一次出現a[i] 的位置 然后從前…

Teams數據統計 - 通話記錄

上篇文章介紹了如何獲取用戶的在線狀態&#xff0c;這篇文章我們記錄介紹如何統計用戶通話記錄。 首先&#xff0c;Teams為了安全&#xff0c;它要求 app 要有 CallRecords.Read.All 權限。然后就可以通過這個api來獲取 call record。 GET /communications/callRecords/{id}這…

linux下mysql的數據庫簡單備份腳本

應用于整個庫的備份。 #!/bin/bash PATH$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin # 數據庫名稱 databases(myname) # 備份目錄 basepath/home/databak/ cd $basepath if [ ! -d "$basepath" ]; thenmkdir -p "$basepath" fi#遍歷數據庫名稱 for …

解決JS浮點數(小數)計算加減乘除的BUG

2019獨角獸企業重金招聘Python工程師標準>>> //浮點數減法運算function FloatSub(arg1,arg2){var r1,r2,m,n;try{r1arg1.toString().split(".")[1].length}catch(e){r10}try{r2arg2.toString().split(".")[1].length}catch(e){r20}mMath.pow(10…

Teams數據統計 - 聊天消息

前兩篇文章介紹了如何對用戶的在線狀態和通話記錄進行數據統計。這篇文章我們來看看如何統計用戶的聊天消息。 在介紹具體 api 如何調用前&#xff0c;我們可以先看一下 Teams 里對于 Message 的層級結構&#xff0c;在 Teams 里&#xff0c;message有兩種&#xff0c;一種是 …

vis.js

1、官網&#xff1a;http://visjs.org/docs/network/ 2、示例&#xff1a; <!doctype html>  <html>     <head>     <title>vis.js</title>     <script type"text/javascript" src"vis.js"></scri…

暑期實習面試——艾锝科技,Python實習生

遠程筆試過&#xff0c;拒絕現場面轉載于:https://www.cnblogs.com/qinziang/p/9123339.html

Teams App 如何使用設備的能力

我們以前講到過&#xff0c;Teams有很多中可以擴展的方面&#xff0c;其中有一種是Tab&#xff0c;開發者可以開發一個web page/app&#xff0c;然后以tab的方式嵌入到teams里面。 除了基本的功能&#xff0c;這種tab也可以使用teams客戶端設備所帶的一些能力&#xff0c;比如…

實驗室3

實驗3.1 1 #include<stdio.h>2 int main()3 { long int sum,i;4 sum0;5 for(i22;i<1003;i20){6 sumsumi;7 }8 printf("sum%ld",sum);9 return 0; 10 } 11 1 #include<stdio.h>2 int main()3 { 4 long int…

寫出整潔的高效的js代碼

Variables:變量 使用有意義的可發音的變量名 Bad: var yyyymmdstr moment().format(YYYY/MM/DD);Good: var yearMonthDay moment().format(YYYY/MM/DD);使用可搜索的命名 在開發過程中&#xff0c;我們閱讀代碼的時間會遠遠超過編寫代碼的時間&#xff0c;因此保證代碼的可讀…

Teams App自定義

當我們開發的 app 被企業安裝后&#xff0c;有些企業挺希望能做一些自定義&#xff0c;如果把app的圖標改的更加符合企業風格一點&#xff0c;或者把app的名字改成讓本企業員工更容易理解一些&#xff0c;或者把app界面的主題色改成個企業風格更加搭配一些&#xff0c;或者對于…