Xml
<imageview
Android:id= "@+id/img"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:src= "@drawable/left"
Android:scaletype= "Fitcenter"
/>
<textview
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:text= "Drag to change the image size"
Android:textsize= "30px"
/>
<seekbar
Android:id= "@+id/sb"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
/>
<textview
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:text= "Drag to rotate Picture"
Android:textsize= "30px"
/>
<seekbar
Android:id= "@+id/sb1"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
/>
There are two of Seekbar
SB Implementation Setonseekbarchangelistener (this); interface
SB1 implementation Setonseekbarchangelistener (this); interface
The idea of dragging the scrollbar to zoom is this, first set the max value of SB to the screen width
Then you can change the size of the Imagview container by dragging the return value to change the size of the picture.
Displaymetrics dm = new Displaymetrics ();
Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); Get the width of the screen
int w = dm.widthpixels;
Sb.setmax (w); Set the maximum value of SB
Drag the scroll bar to rotate the idea first to declare a matrix matrix = new Matrix ();
This class is used for the operation of the picture. Set the degree of his rotation and then load the resource to create a rotated picture
Set this image to a rotated image.
The rotation of the picture does not really let the picture rotate, but a new or a picture and then let the picture rotate, the rotated image to replace the img
It will rewrite the method object. Drag values
public void onprogresschanged (SeekBar SeekBar, int Pro, Boolean arg2) {
int A=seekbar.getid;
Switch (a)
Case R.ID.SB:
int w = Pro;
int h = PRO*3/4;
Linearlayout.layoutparams pra = new Linearlayout.layoutparams (w, h);
Img.setlayoutparams (PRA);
Break
Case R.ID.SB1:
Matrix.setrotate (PRO);
Bitmap Bitmap = Bitmapfactory.decoderesource (Getresources (), r.drawable.left);
Bitmap bit = Bitmap.createbitmap (Bitmap, 0, 0, bitmap.getwidth (),
Bitmap.getheight (), Matrix, True);//Create a rotated picture with a return value of bitmap to create a new bitmap to receive
Img.setimagebitmap (bit); Replace the rotated picture with this picture
Break
}
Set picture size and rotation