Skip to content
Joshua Kovach edited this page Jun 14, 2014 · 4 revisions

The transform effect is the visual effect when a slider changes.

There are 15 preset transform effects you can use by calling:

setPresetTransformer(Transformer ts)

If you want to create your own custom transform effect:

Step 1

Create a class which extends from BaseTransformer

For example:

public class AccordionTransformer extends BaseTransformer {

}

Step 2

Before you override the default behavior, you have to know how the ViewPager transformer works. If you are not familiar with it, please read the screen slide animation tutorial.

Override the onTransform(View view,float position) method:

@Override
protected void onTransform(View view, float position) {
  ViewHelper.setPivotX(view, position < 0 ? 0 : view.getWidth());
  ViewHelper.setScaleX(view, position < 0 ? 1f + position : 1f - position);
}

NOTICE: Please use ViewHelper (thanks to NineOldDroid) to make it compatible with Android 2.2+.

Step 3

Use it.

slider.setPagerTransformer(false,new AccordionTransformer());
Clone this wiki locally