I am designing an app with a .jpeg background and with text views on particular places on the screen. I designed this for my nexus 6 and used dp for the widths and heights of text views and margin-left and margin-top. What my understanding of dp is that it changes with every device according to screen size and density. So it should work on different phones according to the value of dp for them. But this is not the case. When I run that app on a different phone (nexus 5) the layout is all messed up. I tried using the different resources and qualifiers for different screens (large, small, normal). But the problem still prevails. The app considers both nexus 6 and nexus 5 as large screens. How do i fix this?
Asked
Active
Viewed 788 times
-3
-
i tried, it says too long by 4000 characters. im new on SO. tell me how i can share codes. just to tell you what my code is, its a relative layout with an image view. and a than a nested relative layout with a number of text views. – Ismail Khawaja Aug 25 '16 at 07:59
-
Please read [this](https://developer.android.com/training/multiscreen/screensizes.html) and [this](http://stackoverflow.com/questions/8255985/how-to-support-different-screen-size-in-android) – Nikhil Aug 25 '16 at 08:04
-
`NoCodeSampleException in main line 1`! :) put your code here – Masked Man Aug 25 '16 at 08:06
-
There are multiple combinations between density and screen size in Android. Using this kind of configuration (Background image and images that fit the specific position in that background) you need to define your layout for every screen size(small, large, xlarge), and define the correct size of each image for each density(mhdpi, hdpi,xhdpi) – Ricardo Aug 25 '16 at 08:42
1 Answers
0
this is not the best solution i guess.
i guess your layout is just on the layout folder. i don't know if the first device you tested the layout is large or small but what you should do is create another folder named layout-sw600dp. this folder is used by tablets. the folder layout is used my phones and smaller devices. you could also create the layout-land and layout-sw600dp-land folders for the landscape orientation.
dp do change depending on the device but if your layout gets messed up then i guess the layout called by that device doesn't fit its resolution. i guess dp becomes smaller if the device is bigger and vice versa.

rmanalo
- 342
- 3
- 23