In OnCreate when the application starts, fragment1 is called with TextView1 with text. There is a button that switches to another fragment - fragment2 with TextView2 and text in it. So, if you click on the button , it switches to fragment2 . But if you turn the smartphone over, it switches to horizontal orientation and on top of TextView2 , as if in the background, TextView1 opens. If you return back, then even more layered.
As I understand it, when changing the screen orientation, Android calls OnCreate again. How to ban it? But at the same time, so that nothing changes except orientation. That is, if I clicked on the button and read TextView2 , so that when I change the orientation, I stay in the same fragment with the same TextView2 ?
Registered in the Manifesto:
android:configChanges="keyboardHidden|orientation|screenSize" But it did not help. Perhaps you need to add something else, or it is completely wrong. Please tell me how to solve this problem.
add()method, so layering occurs. Add them with thereplace()method and save the state when the configuration changes so that you can restore it later. - pavlofff