How to zoom selected image in gallery in android [duplicate]
I have a gallery in my application. In that gallery I have a lot of images. Can anybody tell me how to zoom in on a selected image in the gallery in android? Please show sample code.
I tried with this code but it's not working:
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent,
View v, int position, long id)
{
if(v!=null)
{
if(position>0){
View previousView=parent.findViewById(position-1);
if(previousView!=null)
{
previousView.setLayoutParams(new Gallery.LayoutParams(100, 120));
}
}
Toast.makeText(getBaseContext(),
"pic" + (position + 1) + " selected",
Toast.LENGTH_SHORT).show();
Animation grow = AnimationUtils.loadAnimation(GalleryActivity.this, R.anim.grow);
v.startAnimation(grow);
v.setLayoutParams(new Gallery.LayoutParams(170, 150));
}
Thanks
This code works
gl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{ public void onItemSelected(AdapterView<?> parent, View v, int
position, long id) {
if (lastview != null) lastview .setLayoutParams(new
Gallery.LayoutParams(140, 280)); lastview = v; v.setLayoutParams(new
Gallery.LayoutParams(170, 340)); }
public void onNothingSelected(AdapterView<?> parent) { //
System.out.println("NOTHING SELECTED");
} });
精彩评论