一个实现 微星 手势滑屏效果 的源代码
public class PagerControl extends View
{
private static final String TAG = "DeezApps.Widget.PagerControl";
private static final int DEFAULT_BAR_COLOR = 0xaa777777;
private static final int DEFAULT_HIGHLIGHT_COLOR = 0xaa999999;
private static final int DEFAULT_FADE_DELAY = 2000;
private static final int DEFAULT_FADE_DURATION = 500;
private int numPages, currentPage, position;
private Paint barPaint, highlightPaint;
private int fadeDelay, fadeDuration;
private float ovalRadius;
private Animation fadeOutAnimation;
public PagerControl(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PagerControl(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.com_deezapps_widget_PagerControl);
int barColor = a.getColor(R.styleable.com_deezapps_widget_PagerControl_barColor, DEFAULT_BAR_COLOR);
int highlightColor = a.getColor(R.styleable.com_deezapps_widget_PagerControl_highlightColor, DEFAULT_HIGHLIGHT_COLOR);
fadeDelay = a.getInteger(R.styleable.com_deezapps_widget_PagerControl_fadeDelay, DEFAULT_FADE_DELAY);
fadeDuration = a.getInteger(R.styleable.com_deezapps_widget_PagerControl_fadeDuration, DEFAULT_FADE_DURATION);
ovalRadius = a.getDimension(R.styleable.com_deezapps_widget_PagerControl_roundRectRadius, 0f);
a.recycle();
barPaint = new Paint();
barPaint.setColor(barColor);
highlightPaint = new Paint();
highlightPaint.setColor(highlightColor);
fadeOutAnimation = new AlphaAnimation(1f, 0f);
fadeOutAnimation.setDuration(fadeDuration);
fadeOutAnimation.setRepeatCount(0);
fadeOutAnimation.setInterpolator(new LinearInterpolator());
fadeOutAnimation.setFillEnabled(true);
fadeOutAnimation.setFillAfter(true);
}