Android: unwanted left / right margins on Nexus 10 in landscape mode

I have a problem with seemingly inexplicable fields that appear to the left and right of my layouts when using the Nexus 10 in landscape mode. I'm sure this is awkwardly straightforward, but I can't find any mention of this in the search.

I'm sure this is not related to my code, because the default Hello World project created by Eclipse demonstrates this phenomenon. The following screenshots are taken from a completely new project, and the only change I made was to make the TextView textSize a little bigger for clarity:

Comparison of landscape and portrait orientations on the Nexus 10

You can see that the default fields from the XML layout file (shown below) are applied correctly in portrait mode, but in landscape mode there is a significant additional margin indicated by a red bar under the screenshot.

<!-- Default screen margins, per the Android Design guidelines. --> <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> 

Has anyone else seen this or had no idea how I can get rid of them? I don’t know where to start, because it looks like a specific device and screen orientation. Plus, this affects the simplest program, as well as my own, so it makes no sense to separate my own code until I find out how to fix the default case.
The same screens are displayed correctly on emulated devices and my Samsung Galaxy S2 (Gingerbread works). Changing the project build goal from the API level from 17 to 10 also did not affect the undesirable effect. Any thoughts?

+6
source share
2 answers

Well, that was awkward right! Fields for Nexus 10 in landscape mode are taken from the resources folder "values-sw720dp-land", which declares a much larger value:

 <!-- Customize dimensions originally defined in res/values/dimens.xml (such as screen margins) for sw720dp devices (eg 10" tablets) in landscape here. --> <dimen name="activity_horizontal_margin">128dp</dimen> 

After almost a year, when I was hiding on SO and finding answers to all my questions, the first one I finally decided to ask correctly is as trivial as this ...

+9
source

Thank danj1974 You saved me a lot of time! I changed the parameter in res / values-w820dp / dens.xml to

 <dimen name="activity_horizontal_margin">0dp</dimen> 

and it works well.

0
source

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


All Articles