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

本文介绍了如何在Android中创建一个自定义的Gallery3D控件,通过详细展示代码实现图片的3D翻转效果,包括缩放、透明度调整和倒影功能。此外,还提供了完整的源码供学习参考。
摘要由CSDN通过智能技术生成

// return position;

}

@Override

public View getCoverFlowItem(int position, View reusableView,

ViewGroup parent) {

ImageView imageView = (ImageView) reusableView;

if (imageView == null) {

imageView = new ImageView(context);

}

Resources re = context.getResources();

InputStream is = re.openRawResource(filmList.get(position%filmList.size()).getRs());

// InputStream is = re.openRawResource(mImagesId[position%mImagesId.length]);

BitmapDrawable mapdraw = new BitmapDrawable(is);

Bitmap bitmap = mapdraw.getBitmap();

imageView.setImageBitmap(BitmapUtil.createReflectedBitmap(bitmap));

// imageView.setImageBitmap(bitmap);

// ps.电影海报宽高比例一般为3:4

imageView.setLayoutParams(new Gallery.LayoutParams(410, 713));

// // 异步加载图片

// imageLoader.displayImage(filmList.get(position % filmList.size())

// .getFilmImageLink(), imageView, options);

imageView.setScaleType(ScaleType.CENTER_CROP);

return imageView;

}

public Integer[] getImagesId(){

return mImagesId;

}

public void setImagesId(Integer[] mImagesId){

this.mImagesId = mImagesId;

}

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() {<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值