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