0

I have two activities in my application both supports portrait and landscape orientation.

  1. Initially application loaded perfect
  2. Rotate my screen to landscape and then come back to portrait, now my portrait views are not showing good as I designed

the layout android:weightSum is not working fine most of the layout weight are reduced

manifest.xml

android:configChanges="keyboardHidden|orientation|screenSize"

How can I solve this issue?

halfer
  • 19,471
  • 17
  • 87
  • 173
Vignesh
  • 546
  • 5
  • 25
  • _now my portrait views are now showing good as I designed_ if it is the same then what is the issue? – Piyush Jun 24 '19 at 09:45
  • sorry man updated the question please check now – Vignesh Jun 24 '19 at 09:46
  • Possible duplicate of [How to handle screen orientation change when progress dialog and background thread active?](https://stackoverflow.com/questions/1111980/how-to-handle-screen-orientation-change-when-progress-dialog-and-background-thre) – weegee Jun 24 '19 at 09:55
  • thanks for your response, my question is entirely different – Vignesh Jun 24 '19 at 10:00
  • my question something like below scenario https://issuetracker.google.com/issues/69168442 – Vignesh Jun 24 '19 at 10:03

1 Answers1

0

Just came across this problem in my own app.

The solution that works for me is as follows:

onCreate(){
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}

onPause(){ 
  if (android.os.Build.VERSION.SDK_INT >= 27) {
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
  }
}

onResume(){
  if (android.os.Build.VERSION.SDK_INT >= 27) {
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
  }
}

The above code should go in the activity that is in landscape mode (i.e. the second activity, and the one you press the back button from)

I would like to point out that this solution was not my own, and I have taken it from the #20 post at the following link (which is also noted in the OP):

https://issuetracker.google.com/issues/69168442

S_i_l_e_n_t C_o_d_e_r
  • 2,179
  • 2
  • 7
  • 21