Android layout with different screen sizes

trying to develop my head around screen sizes, so my application looks the same on different devices.

I have two devices: galaxy s3 and galaxy tab 8. Both have the same screen resolution of 720 x 1280, but s3 is 4.7 inches and the tab is 8 inches.

When I do the linear layout, I indent to 130 from above, so that the first text image is 130 pixels from above, so the background image does not close.

This is good on s3, but when I load it into a tab, the padding should change to 190 pixels so that it looks the same.

I can't tip over if the screen resolution is the same (1280) on both devices. Why do I need a larger addition on the screen.

Is there a way to develop a way to display a text representation in the same place on both devices.

Any help appreciated

Mark

+5
source share
3 answers

Yes, there is a way.

First of all, you should use DP or SP, not PX. The DP block refers to screen size and screen resolution. Here you can see more:

What is the difference between "px", "dp", "dip" and "sp" on Android?

You can also create a folder in res and add different sizes for different devices.

Example:

You already have the "values" of the folder with the file "diameter.xml", there you can add field and size variables.

If you create a folder "values-large" and copy the file "diameter.xml", you can resize the variables and save the name.

In devices "large" it will load different values ​​from other devices.

Here you can see all the documentation: http://developer.android.com/guide/practices/screens_support.html

Hope this helps you.

+2
source

You need to add 2 different layouts for 2 different screen sizes. In fact, you can provide multi-screen support, limited only by your considerations. You can customize the layout to fit your screen. Here is the official documentation that will help you get started.

+1
source

First of all, you need to use dp instead of px to do such things. The reason the result is incorrect is because the number of dots per inch per s3 is much higher than the number of galactic tab 8. You really need to read this link to understand more.

[ http://www.captechconsulting.com/blog/steven-byle/understanding-density-independence-android.BIZ[1]

0
source

Source: https://habr.com/ru/post/1201365/


All Articles