How to change the screen layout according to orientation?

In the portrait I have 5 icons. 4 icons in the first line and 1 icon in the second line. but in the landscape the fifth icon should correspond in the first row. how to solve it?

enter image description here

+3
source share
4 answers

Use different layout files for portrait and landscape positions. Use layout-landfor landscape positions. Android will change the orientation of the landscape when the orientation changes.

+6
source

u , . ( .xml) , . Layout-land , .

-----

- -------

+3

oncreate() mwthod

 if(this.getResources().getConfiguration().orientation ==Configuration.ORIENTATION_PORTRAIT)
 {
    // do code here to arrange the layout as for portrait mode
 }
 else
 {
    // do code here to arrange the layout as for Landscape mode   
 } 

, accrodingly

+1

layout-land android: configChanges = "" .

0

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


All Articles