I have an Activity (which is the launcher of the application) which has a ViewPager as a navigation menu between tabs. Inside this ViewPager I have different type of fragments.
Currently, I'm not handling the orientation changes myself, so the Activity is re-created all over again while I'm rotating my device. (Which behave quite good but I'm not looking into loading the whole activity again because of long loading time and bad user experience).
For a specific Fragment I have 2 layouts (One for portrait and one for landscape).
What I need is to keep the state of the activity and the fragment but to replace fragment layout on orientation change. My problem is that it has extra views in the landscape layout than in portrait so I don't know how to handle it.
I've tried configChanges, but obvisouly it doesn't change my layout. I tried inflate the portrait and landscape layouts and replace them inside a FrameLayout container on onConfigurationChanged, but it doesn't seem to work either.
How can I handle a situation where I need to load a different layout while keeping the fragment state untouched ? Is this even possible ? What is the right approach for this kind of thing ?