I have been fighting with this for 2 days, nothing comes out. In the studio, one thing is different in the emulators!

Suppose I have a 800x600 140 dpi screen (@ 1x), and it has only a horizontal orientation.

I make a layout, in the studio everything looks perfect. For example, I have a 800dp screen, if I indent right and left for 250dp, the content in the center is displayed in a 320dp wide column. 290 + 320 + 290 = 800.

When I run the application in a standard emulator or Genymotion, the central column becomes much thinner - 20dp, that is, as if it were portrait mode! I don't understand at all.

What I have tried, did not help:

  1. Create alternative layouts for the horizon and landscape.
  2. Create alternative layouts with a clearly defined width.
  3. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDCAPE) - it just puts the image on its side, while I see the same narrow strip.

    1 answer 1

    Horizontal orientation can be set in the manifest file.

     <activity android:name="LaunchActivity" android:screenOrientation="landscape"... 

    It is better not to use specific values ​​when setting the dimensions of the elements. You will never adjust the size of the entire zoo devices.

    It will correctly use the android:layout_weight . To do this, assign each element android:layout_width = "0dp" and android:layout_weight="1" , where weight is the percentage that the container should take relative to the parent.

    • And then with the fonts what to do? - Eugene
    • And I have only one very specific screen. I assure you - there will be no others. I would like to understand - if the resolution is at @ x1 800x600dp, why does it behave as if it were worth a portrait. And most importantly, I have absolutely no visual connection between the layout in the IDE and in the emulators. - Eugene
    • the font size value is specified in sp . and if it doesn’t fit to use elipsize, or libraries that automatically fit the size - miha_dev
    • added his answer - miha_dev
    • Here it is - android: screenOrientation = "landscape" - really helped! Thank! - Eugene