0

I created an Android app and tested it on Nexus6 Emulator. Everything seems fine on Nexus6 Emulator but when I ran that app on real devices (Samsung S6 and S5) the layout was all messed up. How can I fix this? Do I have to create separate layout for each device? Does Android have something like 1 layout for all screens?

I dragged and dropped all images in drawable folder instead of using "add image asset". There is nothing in hdpi, mdpi folder. All images are in drawable folder. Is this the cause of my issues? Please advise.

  • 2
    Post your layout code, post a screenshot of both the emulator layout (the way you want it to look) and a screenshot of the "messed" up layout. We literally can't help you if you dont provide some more information. – Moonbloom Nov 26 '16 at 15:03
  • Sounds like you used ImageViews which are scaling to the screen density and messing with the other views. You often need to limit the width and height of ImageView, not just place them in the layout. You can also preview the other screen sizes within android studio – OneCricketeer Nov 26 '16 at 15:09
  • That is correct. I used image views. I will try to set their fixed width and height. – user2949368 Nov 26 '16 at 15:14

1 Answers1

1

It is all about the design of your xml. When designing your pages, try to use 'match parent' and ensure that you are making a layout that fits across all screen resolution. Look into AFAIK...

https://developer.android.com/training/multiscreen/screensizes.html

https://developer.android.com/training/multiscreen/screendensities.html

https://developer.android.com/guide/practices/screens_support.html

How to define dimens.xml for every different screen size in android?

For example:

In your xml

<supports-screens android:smallScreens="true" 
      android:normalScreens="true" 
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true" />
Community
  • 1
  • 1
Andrew Nguyen
  • 106
  • 11