Android Open Source - WheelView Fading Selection Transformer






From Project

Back to project page WheelView.

License

The source code is released under:

Apache License

If you think the Android project WheelView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lukedeighton.wheelview.transformer;
/*from  w w w  .ja  va 2 s .  c o m*/
import android.graphics.drawable.Drawable;

import com.lukedeighton.wheelview.WheelView;

public class FadingSelectionTransformer implements WheelSelectionTransformer  {

    @Override
    public void transform(Drawable drawable, WheelView.ItemState itemState) {
        float relativePosition = Math.abs(itemState.getRelativePosition());
        int alpha = (int) ((1f - Math.pow(relativePosition, 2.5f)) * 255f);

        //clamp to between 0 and 255
        if (alpha > 255) alpha = 255;
        else if (alpha < 0) alpha = 0;

        drawable.setAlpha(alpha);
    }
}




Java Source Code List

com.lukedeighton.wheelsample.MainActivity.java
com.lukedeighton.wheelsample.MaterialColor.java
com.lukedeighton.wheelsample.TextDrawable.java
com.lukedeighton.wheelview.Circle.java
com.lukedeighton.wheelview.WheelView.java
com.lukedeighton.wheelview.adapter.WheelAdapter.java
com.lukedeighton.wheelview.adapter.WheelArrayAdapter.java
com.lukedeighton.wheelview.transformer.FadingSelectionTransformer.java
com.lukedeighton.wheelview.transformer.ScalingItemTransformer.java
com.lukedeighton.wheelview.transformer.SimpleItemTransformer.java
com.lukedeighton.wheelview.transformer.WheelItemTransformer.java
com.lukedeighton.wheelview.transformer.WheelSelectionTransformer.java