Android控件开发之Gallery3D酷炫效果(带源码)

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值