I have 飞溅.png并希望该图像全部出现在屏幕上,就像fitXY
for ImageView
. 飞溅.png尺寸为 480x767。
我必须在代码中更改什么?
public class BitmapConfigView extends LinearLayout {
private Bitmap mImage;
private Paint mPaint = new Paint();
public BitmapConfigView(Context context) {
super(context);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
opts.inScaled = false;
mImage = BitmapFactory.decodeResource( getResources(), R.drawable.splash, opts);
mPaint.setDither(true);
setWillNotDraw(false);
setOrientation(VERTICAL);
setGravity(Gravity.BOTTOM);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(mImage, 0.0f, 0.0f, mPaint);
}
}
缩放位图。这就是您正在寻找的:
android.graphics.Bitmap.createScaledBitmap http://developer.android.com/reference/android/graphics/Bitmap.html#createScaledBitmap%28android.graphics.Bitmap,%20int,%20int,%20boolean%29
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)