想要实现gridview逐条从左到右差序进入
用GridLayoutAnimation实现但是并没有每一行为一单位的效果,所以重写GridLayoutAnimationController
@Override
protected long getDelayForView(View view) {
ViewGroup.LayoutParams lp = view.getLayoutParams();
AnimationParameters params = (AnimationParameters) lp.layoutAnimationParameters;
if (params == null) {
return 0;
}
final int column = getTransformedColumnIndex(params);
final int row = getTransformedRowIndex(params);
final int rowsCount = params.rowsCount;
final int columnsCount = params.columnsCount;
final long duration = mAnimation.getDuration();
final float columnDelay = 0.2f * duration;
final float rowDelay = 0.2f * duration;
float totalDelay;
long viewDelay;
if (mInterpolator == null) {
mInterpolator = new LinearInterpolator();
}
switch (mDirectionPriority) {
case PRIORITY_COLUMN:
viewDelay = (long) (row * rowDelay + column * rowsCount * rowDelay);
totalDelay = rowsCount * rowDelay + columnsCount * rowsCount
* rowDelay;
break;
case PRIORITY_ROW:
viewDelay = (long) (column * columnDelay + row * columnsCount
* columnDelay);
totalDelay = columnsCount * columnDelay + rowsCount * columnsCount
* columnDelay;
break;
case PRIORITY_NONE:
viewDelay = (long) (column * 0.5f + row * columnDelay);
totalDelay = rowDelay + rowsCount * 0.5f;
break;
default:
viewDelay = (long) (column * columnDelay + row * rowDelay);
totalDelay = columnsCount * columnDelay + rowsCount * rowDelay;
break;
}
float normalizedDelay = viewDelay / totalDelay;
normalizedDelay = mInterpolator.getInterpolation(normalizedDelay);
return (long) (normalizedDelay * totalDelay);
}
这要就修改这个方法就可以了