![](/img/trans.png)
[英]how to determine width and height of rectangle drawn on bitmap in a imageview
[英]How to set drawn Bitmap width and height
请,我要设置位图图像的大小。 我从stackover流中搜索了它,但我不明白,我很呆板。
public class Circle extends View{
float y=300 ;
public Circle(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
protected void onDraw(Canvas c){
super.onDraw(c);
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
c.drawBitmap(myBitmap,y,0,null);
Bitmap myBitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
c.drawBitmap(myBitmap,y+100,0,null);
invalidate();
}
}
它看起来是图像的原始尺寸,但我希望它根据不同的屏幕尺寸进行更改。 我已经知道如何在不同的屏幕上进行更改,但是我还不知道如何设置位图大小。 (我正在使用API min-10)。 请给我建议!
您必须对其进行缩放:
mBitmap = Bitmap.createScaledBitmap(mBitmap, newWidth, newHeight, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.