Android自定義帶倒影和偏轉的超炫Gallery,先看下效果圖:
看下主類代碼:
- public class GalleryDemoActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.main);
-
- Integer[] images = { R.drawable.image01,
- R.drawable.image02,
- R.drawable.image03,
- R.drawable.image04,
- R.drawable.image05};
-
- ImageAdapter adapter = new ImageAdapter(this, images);
- adapter.createReflectedImages();//創建倒影效果
- GalleryFlow galleryFlow = (GalleryFlow) this.findViewById(R.id.gallery);
- galleryFlow.setFadingEdgeLength(0);
- galleryFlow.setSpacing(10); //圖片之間的間距
- 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);
- }