Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Android DPI Issue

$
0
0

I'm having some problems with image scaling on android devices. Titanium seems to think that every device I use is 320DPI

I have 2 devices, a Nexus 7 second gen (1920 x 1200 which should be 323 DPI) and an Asus Zenfone 1280 x 720 5" screen which has a calculated DPI of 294 DPI and should use assets from hdpi folder)

when running the following code for the Zenfone

Ti.API.info('Density class: ' + densities[Ti.Platform.displayCaps.density]);
    Ti.API.info('Logical density factor: ' + Ti.Platform.displayCaps.logicalDensityFactor);
    Ti.API.info('DPI: ' + Ti.Platform.displayCaps.dpi);
    Ti.API.info('Height: ' + Ti.Platform.displayCaps.platformHeight);
    Ti.API.info('Width: ' + Ti.Platform.displayCaps.platformWidth);
The output for Zenfone:
displayCaps: {"logicalDensityFactor":2,"bubbleParent":true,"density":"xhigh","xdpi":290.3269958496094,"platformHeight":1280,"platformWidth":720,"apiName":"Ti.Platform.DisplayCaps","ydpi":290.9129943847656,"dpi":320}
[INFO] :   Density class: xhdpi
[INFO] :   Logical density factor: 2
[INFO] :   DPI: 320
[INFO] :   Height: 1280
[INFO] :   Width: 720
For Nexus 7 its :
displayCaps: {"bubbleParent":true,"ydpi":322.96600341796875,"xdpi":320.8420104980469,"logicalDensityFactor":2,"density":"xhigh","platformWidth":1200,"dpi":320,"platformHeight":1824,"apiName":"Ti.Platform.DisplayCaps"}
[INFO] :   Density class: xhdpi
[INFO] :   Logical density factor: 2
[INFO] :   DPI: 320
[INFO] :   Height: 1824
[INFO] :   Width: 1200
The problem is, the zenfone should be using assets from hdpi folder, but its using assets from xhdpi folder and I have confirmed this by making some changes to assets in xhdpi and seeing it reflected on the zenfone

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>