實現漂亮的Activity或者Fragment切換效果:android-player

efbb 9年前發布 | 36K 次閱讀 Android開發 移動開發 android-player

介紹:

實現漂亮的Activity或者Fragment切換效果,兼容api12

運行效果:

使用說明:

你創建了一個漂亮的UI,但是它很單調

svg

運行這個player可以在進入Activity或者Fragment的時候為view創建漂亮的過渡效果。

將它放到Activity的onCreate()或者Fragment的onViewCreated()中。

Player.init().
    animate(headerAction).
    then().
    animate(fabAction).
    then().
    animate(bottomAction).
    play();

效果:

sample_one.gif

其中的三個action分別是這樣定義的:

    final PropertyAction fabAction = PropertyAction.newPropertyAction(activityMainPinkFab).
            scaleX(0).
            scaleY(0).
            duration(750).
            interpolator(new AccelerateDecelerateInterpolator()).
            build();
    final PropertyAction headerAction = PropertyAction.newPropertyAction(activityMainheaderLayout).
            interpolator(new DecelerateInterpolator()).
            translationY(-200).
            duration(550).
            alpha(0.4f).
            build();
    final PropertyAction bottomAction = PropertyAction.newPropertyAction(activityMainMobileNumberLayout).
            translationY(500).
            duration(550).
            alpha(0f).
            build();

自定義

要自定義action,只需繼承BaseAction并實現下面的兩個方法。

    void init(final View view);

    void animate(final View view);

下載

dependencies {
    compile 'com.eftimoff:androidplayer:1.0.0@aar'
}

隨心所欲的制作屬于你的動畫效果

 svg svg

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


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