|
|
@ -52,9 +52,14 @@ public class MyGridLayoutManager extends GridLayoutManager { |
|
|
|
public View onInterceptFocusSearch(View focused, int direction) { |
|
|
|
public View onInterceptFocusSearch(View focused, int direction) { |
|
|
|
int currentPosition = getPosition(getFocusedChild()); |
|
|
|
int currentPosition = getPosition(getFocusedChild()); |
|
|
|
int count = getItemCount()-1; |
|
|
|
int count = getItemCount()-1; |
|
|
|
|
|
|
|
//多少行
|
|
|
|
|
|
|
|
int rowCount = getItemCount() / getSpanCount(); |
|
|
|
switch (direction) { |
|
|
|
switch (direction) { |
|
|
|
case View.FOCUS_DOWN: |
|
|
|
case View.FOCUS_DOWN: |
|
|
|
if (currentPosition + getSpanCount() < count) { |
|
|
|
if(currentPosition /getSpanCount() ==rowCount){ |
|
|
|
|
|
|
|
scrollToPosition(currentPosition); |
|
|
|
|
|
|
|
return findViewByPosition(currentPosition); |
|
|
|
|
|
|
|
}else if (currentPosition + getSpanCount() < count) { |
|
|
|
int nextRowFirstPosition1 = currentPosition + getSpanCount(); |
|
|
|
int nextRowFirstPosition1 = currentPosition + getSpanCount(); |
|
|
|
scrollToPosition(nextRowFirstPosition1); |
|
|
|
scrollToPosition(nextRowFirstPosition1); |
|
|
|
return findViewByPosition(nextRowFirstPosition1); |
|
|
|
return findViewByPosition(nextRowFirstPosition1); |
|
|
|