3.创建Activity:
public class Gallery3DActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_gallery); Integer[] images = { R.drawable.img0001, R.drawable.img0030, R.drawable.img0100, R.drawable.img0130, R.drawable.img0200, R.drawable.img0230, R.drawable.img0330,R.drawable.img0354 }; ImageAdapter adapter = new ImageAdapter(this, images); adapter.createReflectedImages();//创建倒影效果 GalleryFlow galleryFlow = (GalleryFlow) this.findViewById(R.id.Gallery01); galleryFlow.setFadingEdgeLength(0); galleryFlow.setSpacing(-100); //图片之间的间距 galleryFlow.setAdapter(adapter); galleryFlow.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getApplicationContext(), String.valueOf(position), Toast.LENGTH_SHORT).show(); } }); galleryFlow.setSelection(4); } }以上实现代码里面我都做了注释相信大家完全可以看懂。稍微解释下,在BaseAdapter中主要做了图片的倒影效果以及创建了对原始图片和倒影的显示区域。GalleryFlow中主要做了对图片的旋转和缩放操作,根据图片的屏幕中的位置对其进行旋转缩放操作。