How to change automatically dimensions of margins in android views when screen orientation change?

StackOverflow https://stackoverflow.com/questions/21818177

Question

I see that in this file: "dimens.xml" there are two properties:

<dimen name="activity_horizontal_margin">5dp</dimen>
<dimen name="activity_vertical_margin">10dp</dimen>

is there a way to change automatically the margin of a view depending on the screen orientation using this file?

Or those two properties are there just like an attribute and I have to check manually every time that the orientation change and set that attribute to the layout margins???

Thanks in advance!

Was it helpful?

Solution

I assume your file is in the res/values folder in your project. Create a copy of the file in a folder called res/values-land in your project, and modify the values as needed. That file will be used automatically when in landscape orientation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top