实现Activity的波纹动画效果:WaveCompat
jopen
10年前
介绍:
实现Activity的波纹动画效果。
运行效果:

使用说明:
1. 将被点击之后调用activity
的View和touch helper绑定:
WaveTouchHelper.bindWaveTouchHelper(view, onWaveTouchHelperListener);
2.在OnWaveTouchHelperListener中重写onWaveTouchUp()方法:
@Override public void onWaveTouchUp(View view, Point locationInView, Point locationInScreen) { WaveCompat.startWaveFilter(this, new WaveDrawable() .setColor(0xff8B2252) .setTouchPoint(locationInScreen), generateIntent(0xff8B2252)); } private Intent generateIntent(int color) { Intent intent = new Intent(context, SecondWareTestActivity.class); intent.putExtra("color", color); return intent; }
3. TO activity的默认初始transition
(可选)
getWindow().setBackgroundDrawable(new ColorDrawable((backgroundFromColor = getIntent().getIntExtra(WaveCompat.IntentKey.BACKGROUND_COLOR, 0xff8B7D6B)))); WaveCompat.transitionInitial(this, ABTextUtil.dip2px(context, 80), backgroundFromColor, Color.GRAY);