// 滚动到请求focus的子控件处。 if (!mIsLayoutDirty) { scrollToChild(focused); } else { // The child may not be laid out yet, we can't compute the scroll yet mChildToScrollTo = focused; }
When looking for focus in children of a scroll view, need to be a little more careful not to give focus to something that is scrolled off screen. This is more expensive than the default android.view.ViewGroupimplementation, otherwise this behavior might have been made the default.
1 2 3 4 5 6 7 8
protectedbooleanonRequestFocusInDescendants(int direction, Rect previouslyFocusedRect){ ... // 如果不在显示范围内,跳走 if (isOffScreen(nextFocus)) returnfalse; ... }