@Override
public void requestLayout() {
mIsLayoutDirty = true;
super.requestLayout();
}

所以我们在执行requestChildFocus的时候,会进入else的判断,mChildToScrollTo = focused。

2.接下来我们继续分析下mParent.requestChildFocus(this, focused)方法?

android.view.ViewGroup{
@Override
public void requestChildFocus(View child,
View focused) {
if (DBG) {
System.out.println(this + " requestChildFocus()");
}
if (getDescendantFocusability() == FOCUS_BLOCK_DESCENDANTS) {
return;
}

// Unfocus us, if necessary
super.unFocus(focused);

// We had a previous notion of who had focus. Clear it.
if (mFocused != child) {
if (mFocused != null) {
mFocused.unFocus(focused);
}

mFocused = child;
}
if (

public class PageUpGridLayoutManag er extends GridLayoutManag er { private RecyclerView recyclerView ; private Handl er mHandl er ; private long time = 8000; // 滚动 时间 引言,有一天我在调试一个界面,xml布局里面包含 Scroll View,里面嵌套了 recyclerView 的时候,界面一进去,就 自动 滚动 到了 recyclerView 的那部分,百思不得其解,上网查了好多资料,大部分只是提到了解决的办法,但是对于为什么 这样,都 没有 一个很好的解释,本着对技术的负责的态度,花费了一点时间将前后理顺了下 1.首先... 上面代码实现了最基本的 滚动 功能,但有时候Adnroid设备可以触摸的话,而当前 recyclerview 正在 滚动 ,又去滑动它,那就 造成界面错乱,数据错乱了,所以还需要重写拦截onTouchEvent方法,当触摸到 recyclerview 的时候,即在ACTION_DOWN的时,停止 滚动 线程,在ACTION_UP、ACTION_CANCEL时再开启线程。 概要做一个 自动 滑动的列表,用于展示聊天记录或者通知栏信息等,还是使用主流的 RecyclerView 来做。网上有很多案例,但当手动滑动时 一直无限循环,数据重复的出现,如果想要 自动 滑动时能无限循环,手动滑动时又能滑到底呢?本案例就解决这种手动滑动和 自动 滑动无缝斜街的问题。1、重写 RecyclerView ,通过 scroll By和postDelayed进行定时移动到达 自动 滑动目的2、 RecyclerView 添加addOn Scroll Listen er ,进行手指按下滑动和抬起监听,用于判断是手动滑动还是 自动 滑动。3、 scroll -view本身不支持 自动 滚动 ,通过 scroll -top属性控制 滚动 ,但是不可以循环 滚动 。使用swip er 组件实现很简单,封装下即可用,且支持衔接滑动。