To change accordingly to landscape/portrait mode

后端 未结 2 1034
余生分开走
余生分开走 2021-01-23 10:08

I have a date/time picker which I want them to react according based on its layout.

Consider on landscape mode:

This is a perfect placement of what I

相关标签:
2条回答
  • 2021-01-23 10:30

    When screen orientation change than activity again recreated so do this :

    int orientation = this.getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
     //code for portrait mode
    } else {
    //code for landscape mode
    }
    

    Happy coding!!

    0 讨论(0)
  • 2021-01-23 10:48

    You can create a layout-land directory that contains landscape layouts of your screens. In this case you would place the original layout inside the layout-land directory and place the orientation:vertical layout inside your layout folder.

    The Android documentation has information on how to support different screens

    0 讨论(0)
提交回复
热议问题