Layout highlights:
// Distance from the bottom of the previous control
Android: layout_margintop = "10dp"
CodePhase Analysis:
// Return the printable view and convert it down to the printable view of Bitmap.
Bitmapdrawable = (bitmapdrawable) image1.getdrawable ();
// If the image has not been recycled, forcibly recycle the image first.
If (! Bitmapdrawable. getbitmap (). isrecycled ())
{
Bitmapdrawable. getbitmap (). Recycle ();
}
// Change the image displayed in the imageview
Image1.setimagebitmap (bitmapfactory. decoderesource (getresources (), images [++ currentimg]);
// Capture the original image for display
1. Use setontouchlistener to listen
2. Obtain the screen width for obtaining the actual proportion in step 3.
Displaymetrics dm = new displaymetrics ();
Getwindowmanager (). getdefaultdisplay (). getmetrics (DM );
System. Out. println (DM. widthpixels );
3. ObtainThe actual bitmap image size and the scaling ratio of the first imageview
Double scale = bitmap. getwidth ()/DM. widthpixels;
4. Get the start point of the image to be displayed
Int x = (INT) (event. getx () * scale );
Int y = (INT) (event. Gety () * scale );
5.AlgorithmThe specified start point and display area cannot be greater than the image area
If (x + 120> bitmap. getwidth ())
{
X = bitmap. getwidth ()-120;
}
If (Y + 120> bitmap. getheight ())
{
Y = bitmap. getheight ()-120;
}
6. display the specified area of the image
Image2.setimagebitmap (bitmap. createbitmap (bitmap, X, Y, 120,120 ));