實現Activity的波紋動畫效果:WaveCompat

jopen 9年前發布 | 18K 次閱讀 Android開發 移動開發 WaveCompat

介紹:

實現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);

項目主頁:http://www.baiduhome.net/lib/view/home/1434356814458

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!