Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom ImageView getting resized automatically on Nexus 7

I have a custom ImageView that covers the whole screen. The image is sourced from one of the drawable folders, drawable-hdpi, drawable-xhdpi, drawable-sw600dp etc. and there are separate images for each density bucket.

So far, the application works fine on xhdpi and hdpi devices, the problem occurs when I test it on a Nexus 7. The image stored in the sw600dp folder has a size of 1600x1600 and should be enough to directly draw on the screen (without scaling), however when I run the app, the screen turns out to be completely blank and I get the following warning:

03-04 16:25:46.338: W/OpenGLRenderer(25457): Bitmap too large to be uploaded into a texture (2130x2130, max=2048x2048)

For some reason the 1600x1600 bitmap is scaled to 2130x2130 although I have not manually scaled it anywhere (no matrix postscale or scaleX/scaleY applied)

Any thoughts on why this might be happening? Please provide a solution along with the explanation of why this might be happening.

like image 469
Soham Avatar asked Mar 04 '13 11:03

Soham


1 Answers

Since Nexus 7 is tvdpi, it scales every image to 1.33 of the original value. So 1600 becomes (1600*1.33)= ~2130. It wont display it from the sw600dp folder.

More Info:-http://developer.android.com/guide/practices/screens_support.html

You can use the same image which you are using for every other 7 inch tablet ( i.e. of resolution 1024*600 ).

like image 50
Kunalxigxag Avatar answered Oct 22 '22 09:10

Kunalxigxag