Android自定义动画之广告牌翻动效果

懒得写多少没用的,直接把README贴上来得了。
这是源码github地址

若你对代码实现有啥疑惑欢迎前来咨询。

Billboard

Transition the views as billboard.



See it on Youtube

How to include

dependencies {
    compile 'com.zql.android:billboard:1.1'
}

Usage

1. write the code in layout




    


2. start Billboard

billboard = (Billboard) findViewById(R.id.billboard);
billboard.setCallback(new Billboard.BillboardCallback() {
    @Override
    public Bitmap getBitmap(int count) {
        if(count%5 == 0){
            return BitmapFactory.decodeResource(getResources(),R.mipmap.b1);
        }
        if(count%5 == 1){
            return BitmapFactory.decodeResource(getResources(),R.mipmap.b2);
        }
        if(count%5== 2){
            return BitmapFactory.decodeResource(getResources(),R.mipmap.b3);
        }
        if(count%5 == 3){
            return BitmapFactory.decodeResource(getResources(),R.mipmap.b4);
        }
        if(count%5 == 4){
            return BitmapFactory.decodeResource(getResources(),R.mipmap.b5);
        }
        return null;
    }
    @Override
    public long getDelayFactor(int index, int slipSize,long delay) {
        return index * delay;
    }
});
billboard.go();

api

xml

property format default value meaning
billboard_columns integer 10 count that billborad will be cut in horizontal
billboard_rows integer 1 count that billborad will be cut in vertical
billboard_duration integer 1000 animation duration of one slip
billboard_delay integer 300 the time delay of next slip do it animatin
billboard_refresh integer 3000 time of two image transition
billboard_orientation string horizontal orientation of slip's animatin

java

    /**
     * set the callback
     * @param callback {@link BillboardCallback}
     */
    Billboard.setCallback(BillboardCallback callback)

    /**
     * {@link Billboard}'s callback
     */
    public interface BillboardCallback {
        /**
         * get a bitmap to show
         * @param count {0,1,2,3,4,5,6,7,8, ... ,Integer.MAX_VALUE}
         * @return
         */
        Bitmap getBitmap(int count);
    /**
         * custom the delay time of every slip
         * @param index slip index
         * @param delay the time you define in layout xml
         * @param slipSize the size of slip
         * @return delayfactor
         */
        long getDelayFactor(int index,int slipSize,long delay);
    }

    /**
     * start flip
     */
    Billboard.go()

    /**
     * end flip
     */
    Billboard.endFlip()

    /**
     * set timeInterpolator of flip animation
     * @param timeInterpolator
     */
    Billboard.setTimeInterpolator(TimeInterpolator timeInterpolator)

version 1.1

Add a method in BillboardCallback to custom the flip order.

/**
 * custom the delay time of every slip
* @param index slip index
* @param delay the time you define in layout xml
* @param slipSize the size of slip
* @return delayfactor
*/
long getDelayFactor(int index,int slipSize,long delay);

for example:

index * delay make the order from left to right.

@Override
public long getDelayFactor(int index, int slipSize,long delay) {
    return index * delay;
}

你可能感兴趣的:(Android自定义动画之广告牌翻动效果)