歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android自定義帶倒影和偏轉的超炫Gallery

Android自定義帶倒影和偏轉的超炫Gallery

日期:2017/3/1 10:19:10   编辑:Linux編程

Android自定義帶倒影和偏轉的超炫Gallery,先看下效果圖:

看下主類代碼:

  1. public class GalleryDemoActivity extends Activity {
  2. /** Called when the activity is first created. */
  3. @Override
  4. public void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. requestWindowFeature(Window.FEATURE_NO_TITLE);
  7. setContentView(R.layout.main);
  8. Integer[] images = { R.drawable.image01,
  9. R.drawable.image02,
  10. R.drawable.image03,
  11. R.drawable.image04,
  12. R.drawable.image05};
  13. ImageAdapter adapter = new ImageAdapter(this, images);
  14. adapter.createReflectedImages();//創建倒影效果
  15. GalleryFlow galleryFlow = (GalleryFlow) this.findViewById(R.id.gallery);
  16. galleryFlow.setFadingEdgeLength(0);
  17. galleryFlow.setSpacing(10); //圖片之間的間距
  18. galleryFlow.setAdapter(adapter);
  19. galleryFlow.setOnItemClickListener(new OnItemClickListener() {
  20. public void onItemClick(AdapterView<?> parent, View view,
  21. int position, long id) {
  22. Toast.makeText(getApplicationContext(), String.valueOf(position), Toast.LENGTH_SHORT).show();
  23. }
  24. });
  25. galleryFlow.setSelection(4);
  26. }
Copyright © Linux教程網 All Rights Reserved