Android ImageView Zoom-in and Zoom-Out

前端 未结 23 2364
死守一世寂寞
死守一世寂寞 2020-11-22 09:31

I want to Zoom-in and Zoom-out an Android ImageView. I tried most of the samples but in all of them the image in the ImageView itself is getting Zoomed-in and Zoomed-out, wh

23条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 10:14

    Step 1: First you add dependencies in build.gradle(Module:app) file.

    dependencies {
    
         implementation 'com.jsibbold:zoomage:1.2.0'
    
        }
    

    Step 2: Next create a class

    ImageFullScreenFragment.java

    public class ImageFullScreenFragment{
    
       private ZoomageView ImageZoomageView;
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            View view = null;
    
          try {
             view = inflater.inflate(R.layout.fragment_image_full_screen, container, false);
                ImageZoomageView = view.findViewById(R.id.imageViewImageFullScreen);
                ImageZoomageView.setImageResource(R.drawable.image);
    
             } catch (Exception e) {
                 e.printStackTrace();
             }
        return view;
    
    }
    

    Step 3 : Next create a layout xml file

    fragment_image_full_screen.xml

    
    
    
        
    
    
    

    OutPut:-

提交回复
热议问题