I am using an Image view with these XML attributes
<ImageView
android:id="@+id/widget_list_bitmap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:scaleType="center"
android:src="@drawable/place_holder" >
</ImageView>
and at runtime I create a let’s say 400×400 bitmap, save it to a file and set the ImageView src using a file URI
remoteViews.setUri(R.id.widget_list_bitmap, “setImageURI”, myFileUri);
(this is to avoid RemoteViews issues with large bitmaps).
Everything works fine except that the displayed image is scaled down and is smaller than 400×400, more like 250 x 250 (possibly 400/density, density = 1.5).
Is there a way to force an ImageView to really not scaling images it fetches from URI?
You could manually download it and when you load it with
BitmapFactorysetinScaledto false. Then you would usesetImageViewBitmapinstead ofsetUriorsetImageViewUri.Update:
Unfortunately I don’t really see a way around this using
setUri. An alternative to usingsetUrito get around the 1MB limit is to usesetImageViewBitmapbut slice up the bitmap and display it on multiple views, maybe a 2×2 or 3×3 grid of ImageViews or something like that. You’d have to split it into multiple updates usingpartiallyUpdateAppWidget, but I think it should work. The hitch is that this requires API 11.