I have splash.png and want that this image take all place on the screen like fitXY
for ImageView
. splash.png has sizes 480x767.
What does I must to change in my code?
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);
}
}
Scale the bitmap. This is what you're looking for:
android.graphics.Bitmap.createScaledBitmap
This is how i usually do mine with a scale method.
As a result, I used
WebView
:main.xml
6.html