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.
How to change automatically dimensions of margins in android views when screen orientation change?
-
12-10-2022 - |
题
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!
解决方案
不隶属于 StackOverflow