mdpi image is too small for 10" android tablet

后端 未结 4 1914
我在风中等你
我在风中等你 2020-12-24 07:54

I have drawables for each density as ldpi,mdpi,hdpi and xhdpi.

Problem: Both 10\" tablet device (1280x800) and a handset device 320x480 uses medium density

4条回答
  •  别那么骄傲
    2020-12-24 08:23

    I include some resources in drawable-xlarge, and drawable-large folders, in addition to the drawable-hdpi folders. This works for me.

    Another alternative, is to scale an image in code directly, which I do with the following code:

    Drawable scaledIcon = new BitmapDrawable(Bitmap.createScaledBitmap(myImage, pxInt, pxInt, true));
    myImageView.setBackgroundDrawable(scaledIcon);
    

    It is not a good idea to scale a lot of images in your code (using this method), as I think it is resource intensive to modify the images on the fly like this. I do use this in some cases, where the image I am using may not be a standard size (and I want it to fit right always).

提交回复
热议问题