开发者

How to zoom selected image in gallery in android [duplicate]

开发者 https://www.devze.com 2023-03-07 17:57 出处:网络
This question already has answers here: 开发者_如何学Go Android Gallery zoom in/out (4 answers) Closed 9 years ago.
This question already has answers here: 开发者_如何学Go Android Gallery zoom in/out (4 answers) Closed 9 years ago.

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");

      } });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号