我有一个splash.png图片,希望让它像ImageView
的fitXY
一样占据整个屏幕。该图片的尺寸为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);
}
}