How to scale the imageview and view with matrix using seekBar?

456 views Asked by At

I use the code below to scale my image view when event happen. But I want the view to be enlarged or reduced with image view. How can I achieve that effect? track the seekbar the scaled image view hide.

private void seekBarScale(ImageView imgew) {
        // TODO Auto-generated method stub
        mImgeView = imgew;
           seekbarscale.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                    // TODO Auto-generated method stub

                }               

                @Override
                public void onProgressChanged(SeekBar seekBar, int progresValue,
                        boolean fromUser) {
                    int progress=0;
                     progress = progresValue;                       
                                                                mImgeView.setScaleType(ScaleType.MATRIX);                   

                     BitmapDrawable drawable = (BitmapDrawable)mImgeView.getDrawable();
                     Bitmap viewBitmap = drawable.getBitmap();

                      int bmpWidth = viewBitmap.getWidth();
                      int  bmpHeight = viewBitmap.getHeight();
                    seekbarscale.setMax(5);

                     int scale=(int) ((progress/10.0f)+0.5f);

                     float x = mImgeView.getScaleX();
                        float y = mImgeView.getScaleY();

                        float scalex=(x+progresValue);
                        float scaley=(y+progresValue);

                        //img.setScaleY((float) (y+progresValue));
                     Matrix matrix = new Matrix();
                        mImgeView.setScaleType(ScaleType.MATRIX);   
                        matrix.postScale(scale,scale,bmpWidth/2, bmpHeight/2);          
                        mImgeView.setImageMatrix(matrix);                  

when i track the seek bar image was scaled but not show in full view how will achieve this? show only center part of scaled image only remaining part hide.how to get view height,width and apply into matrix could u please help me ? zoom in zoom out they apply post translate in matrix but here i don't know how to apply?

0

There are 0 answers