private Integer mImagesId[] = {
R.drawable.ic_1,
R.drawable.ic_3,
R.drawable.ic_2,
R.drawable.ic_4,
R.drawable.ic_5
};
三:gallery 控件类
缩放,还有透明,等等都在这里设置
public class FancyCoverFlow extends Gallery {
public static final int ACTION_DISTANCE_AUTO = Integer.MAX_VALUE;
/**
- 图片向上突出,可以通过代码控制,也可以在xml上控制
*/
public static final float SCALEDOWN_GRAVITY_TOP = 0.0f;
/**
- 图片中间突出
*/
public static final float SCALEDOWN_GRAVITY_CENTER = 0.5f;
/**
- 图片向下突出
*/
public static final float SCALEDOWN_GRAVITY_BOTTOM = 1.0f;
private float reflectionRatio = 0.3f;
private int reflectionGap = 4;
private boolean reflectionEnabled = false;
private float unselectedAlpha;
private Camera transformationCamera;
private int maxRotation = 0;
private float unselectedScale;
private float scaleDownGravity = SCALEDOWN_GRAVITY_CENTER;
private int actionDistance;
private float unselectedSaturation;
public FancyCoverFlow(Context context) {
super(context);
this.initialize();
}
public FancyCoverFlow(Context context, AttributeSet attrs) {
super(context, attrs);
this.initialize();
this.applyXmlAttributes(attrs);
}
@SuppressLint(“NewApi”)
public FancyCoverFlow(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (Build.VERSION.SDK_INT >= 11) {
this.setLayerType(LAYER_TYPE_SOFTWARE, null);
}
this.initialize();
this.applyXmlAttributes(attrs);
}
private void initialize() {
this.transformationCamera = new Camera();
this.setSpacing(0);
}
private void applyXmlAttributes(AttributeSet attrs) {
TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.FancyCoverFlow);
this.actionDistance = a
.getInteger(R.styleable.FancyCoverFlow_actionDistance,
ACTION_DISTANCE_AUTO);
this.scaleDownGravity = a.getFloat(
R.styleable.FancyCoverFlow_scaleDownGravity, 0.5f);