At the beginning of Android, I wrote a simple image scaling program. After a little time, it seems necessary to record it.
Layout code:
<FrameLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: layout_gravity = "clip_vertical"> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: gravity = "bottom | center_horizontal" android: orientation = "horizontal"> <Button android: id = "@ + id/bsx" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = ""/> <Button android: id = "@ + id/bfd" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "zoom in"/> </LinearLayout> <LinearLayout android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: orientation = "vertical"> <ImageView android: id = "@ + id/img" android: layout_width = "wrap_content" android: layout_height = "wrap_content"> </ImageView> </LinearLayout> </FrameLayout>
Java code:
MainActivity Activity screenWidth; screenHeight; scaleWidth = 1f; scaleHeight = @Override == == dm.heightPixels - 80= (ImageView) = (Button) = (Button) @Override (v.getId() == R.id.bfd) { scaleWidth *= 1.2*= 1.2 { scaleWidth *= 0.8*= 0.8 width = height == (width * scaleWidth > screenWidth|| height * scaleHeight >== tewmpmap = Bitmap.createBitmap(bmp, 0, 0, width, height, ma,