GridView 行动画

想要实现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);
	}
这要就修改这个方法就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值