程序中有一个splash.png,想让这张图能占据整个屏幕,就像ImageView 中的fitXY。
splash.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);
}
}