Android R - image very tiny
Opened this issue ยท 5 comments
Expected behaviour
Should work the same as Android Q - Image should match view size.
Actual behaviour
On Android R preview the images show up very small - like 5x5 pixels.
Steps to reproduce
Using glide to get bitmap of remote image.
request.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
imageView.setImage(ImageSource.bitmap(resource));
}
});
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Affected devices
Android R
Affected images
Any
I have reproduced this in an emulator. It is happening because Android is reporting the screen pixel density is 2.75 pixels per inch, when the real value is 440. I suspect this is an emulator bug. Do you have a real device to test it on?
Unfortunately I do not. Hopefully you're right and I'll keep an eye on the R preview releases to see if it gets resolved on that end.
I have installed the Android R developer preview on my old Pixel 2 and it is not affected by this problem. Everything seems to work as it should.
It seems that this issue happens on emulators and some select devices (e.g. Nokia 6.1 on android 10 and higher on custom ROMs) because they report invalid ydpi and xdpi
Perhaps use densityDpi if xdpi and ydpi are suspiciously low?