我有一个 ImageView,我想一次只显示一部分。但从相同的 x,y 坐标开始。是否有捷径可寻?
问问题
1377 次
2 回答
0
看看这个
Drawable drawable = getResources().getDrawable(R.drawable.image);
Bitmap bitmap = ((BitmapDrawable) drawable ).getBitmap();
bitmap= Bitmap.createBitmap(bitmap , startX, startY, width, height);
imgview.setBackgroundDrawable(new BitmapDrawable(bitmap));
你也可以调整你的形象
Bitmap resizedImage = Bitmap.createScaledBitmap(bitmap, scrwidth, scrwidth, false);
于 2012-04-04T14:41:39.000 回答
0
使用 x 和 y 调整图片大小
top = 0;
bottom = bitmap.getHeight() / 2; //half of picture
Bitmap croppedBitmap = Bitmap.createBitmap(toBeCropped, 0, top,
toBeCropped.getWidth(), bottom);
第二半可以调整大小
top = (bitmap.getHeight() / 2);//starting from here (half)
bottom = (bitmap.getHeight() / 2) ;
Bitmap croppedBitmap = Bitmap.createBitmap(toBeCropped, 0, top,
toBeCropped.getWidth(), bottom);
希望这会对你有所帮助
于 2020-11-09T07:26:41.680 回答