說(shuō)一下recycleView的自動(dòng)滾動(dòng)問(wèn)題

網(wǎng)上無(wú)非就是告訴你要加上android:descendantFocusability=”blocksDescendants”
然后就抄來(lái)抄去的萬(wàn)事。
其實(shí)本來(lái)我是拒絕的。
上次看源碼還是7年前。
但是公司最近事情少,實(shí)在無(wú)聊。就點(diǎn)進(jìn)去了解了一下。

private void recoverFocusFromState() {
        if (!mPreserveFocusAfterLayout || mAdapter == null || !hasFocus()
                || getDescendantFocusability() == FOCUS_BLOCK_DESCENDANTS
                || (getDescendantFocusability() == FOCUS_BEFORE_DESCENDANTS && isFocused())) {
            // No-op if either of these cases happens:
            // 1. RV has no focus, or 2. RV blocks focus to its children, or 3. RV takes focus
            // before its children and is focused (i.e. it already stole the focus away from its
            // descendants).
            return;
        }

可以看到。這里有用到我們的設(shè)置項(xiàng)。
其實(shí)就是不再去檢查子view的焦點(diǎn)。所以直接返回

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容