0

My most resend project involves a Samsung Tab A 9.7" with 1024x768 pixels in a 4:3 format. This tablet is quite new and this format is unfortionatelly not supported by Android Studio so I've tried adding a new virtual device with these resolutions. I've set the scale option to: '1dp on device = 1px on screen'

The thing that seems wrong, is there is a difference between dp and px. If, for example, the width of a view is set to 1024px, it lines up nicely with the borders of the screen. But if I set it to 1024dp, it is much smaller... 1dp=1px means it is supposed to be the same, right? When I launch it on the tab, all content gets wrong sizes etc (due to the problem above ofc).

Is there a way to propper add a 4:3 resolition so it can be used in the layout editor? I know there is a difference between px and dp but 1/1 is supposed to be the same?

Thanks a lot,

Jesse

JesseB1234
  • 147
  • 7
  • I know that this doesnt answer your question, but with some luck it will make the answer unneeded, please consider this http://stackoverflow.com/questions/29956014/why-should-we-use-xml-layouts – Nanoc Nov 04 '15 at 15:59
  • Not really, not sure what the probles is exacly... Today I've tried changing a width to 512px and run it on the tab. It fits correctly to the center of the screen. But if I change px to dp, – JesseB1234 Nov 05 '15 at 14:08
  • On the web I've found a converter from px to dp. 512px should be the same as 682.67dp, which it does inside the editor (again, neatly till the centre) But here is the but, if I run it on the tab (with 682.67dp), it appears bigger, till about 3/4 of the screen?! Am I being stupid? What kind of black magic is happening here? – JesseB1234 Nov 05 '15 at 14:15
  • The px to dp ratio changes between devices, it isnt always 100% precise – Nanoc Nov 05 '15 at 14:31

1 Answers1

0

After a long mixture between research and trail and error, finally 'found' the cause. When adding a virtual device in android studio for a custom resolution, it automatically focuses on portrait mode I think. Putting a view till the middle in portrait mode inside the editor -> In the middle in landscape on the tablet. Not sure if this is mend to be or an error of some kind.

Found out you can use the Nexus 9 layout, also 4:3 (2048 x 1538).

Thanks for the support Nanoc

JesseB1234
  • 147
  • 7