```java
public class FocusedLayoutManager extends GridLayoutManager {
    public FocusedLayoutManager(Context context, int spanCount) {
        super(context, spanCount);
    }

    public View onInterceptFocusSearch(View focused, int direction) {

        int currentPosition = getPosition(getFocusedChild());//这里要用这个方法
        int count = getItemCount();
        int lastVisiblePosition = findLastVisibleItemPosition();
        switch (direction) {
            case View.FOCUS_RIGHT:
                currentPosition++;
                break;
            case View.FOCUS_LEFT:
                currentPosition--;
                break;
        }
        if (currentPosition < 0 || currentPosition > count) {
            return focused;
        } else {
            if (currentPosition > lastVisiblePosition) {
                scrollToPosition(currentPosition);
            }
        }
        return super.onInterceptFocusSearch(focused, direction);
    }
}
```

