歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

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

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.           
  9.         Integer[] images = { R.drawable.image01,   
  10.                              R.drawable.image02,   
  11.                              R.drawable.image03,   
  12.                              R.drawable.image04,   
  13.                              R.drawable.image05};  
  14.           
  15.         ImageAdapter adapter = new ImageAdapter(this, images);  
  16.         adapter.createReflectedImages();//創建倒影效果   
  17.         GalleryFlow galleryFlow = (GalleryFlow) this.findViewById(R.id.gallery);  
  18.         galleryFlow.setFadingEdgeLength(0);  
  19.         galleryFlow.setSpacing(10); //圖片之間的間距   
  20.         galleryFlow.setAdapter(adapter);  
  21.           
  22.         galleryFlow.setOnItemClickListener(new OnItemClickListener() {  
  23.             public void onItemClick(AdapterView<?> parent, View view,  
  24.                     int position, long id) {  
  25.                 Toast.makeText(getApplicationContext(), String.valueOf(position), Toast.LENGTH_SHORT).show();  
  26.             }  
  27.               
  28.         });  
  29.         galleryFlow.setSelection(4);  
  30.     }  
Copyright © Linux教程網 All Rights Reserved