Step 1 : create a simple Linear-layout
with an ImageSwitcher & a gallery view.
Step 2: include neccessary animation
xml files , like fade in, fade out.
public class MyImageSwitcher extends Activity implements AdapterView.OnItemSelectedListener, ViewSwitcher.ViewFactory { // create array of thumbnail & image Ids private Integer[] mThumbIds = { R.drawable.homeapp1,R.drawable.homeapp3,R.drawable.homeapp4}; private Integer[] mImageIds = {R.drawable.homeapp1,R.drawable.homeapp3,R.drawable.homeapp4}; String category; ViewFlipper mFlipper; private ImageSwitcher mSwitcher; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.image_switcher_1); mSwitcher = (ImageSwitcher) findViewById(R.id.switcher); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); Gallery g = (Gallery) findViewById(R.id.gallery); g.setAdapter(new ImageAdapter(this)); g.setOnItemSelectedListener(this); } public void onItemSelected(AdapterView parent, View v, int position, long id) { mSwitcher.setImageResource(mImageIds[position]); } public void onNothingSelected(AdapterView parent) { } public View makeView() { ImageView i = new ImageView(this); i.setBackgroundColor(0xFF000000); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); return i; } public class ImageAdapter extends BaseAdapter { //write your own implementation for returning Images from getView method } }
how to set image switcher gallery in vertical view..........