I am facing a issue which i need to resolve by making my view intelligent about what type of view is used currently.
I have two layout one for Portrait and another for landscape(land).
- MyFragmentLayout.xml
- MyFragmentLayout.xml (land)
I am currently setting my child View of the Fragment with some Padding and i want the view to know which type of layout is currently in use.(Portrait/Landscape). This is my code i used:
val verticalPadding = if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50f, displayMetrics)
else
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 150f, displayMetrics)
Above work's perfectly for orientation change case.
Problem:
I am giving Multi-Window support to my application And the issue i am facing is when Window is in portrait mode (i.e orientation is Portrait)
But application due to region available switches the layout from portrait mode to landscape mode.
As you can see the upper window with red bar is in Portrait mode but Application use's it's Landscape Layout.(which is perfect for my case)
I want to know how can know which type of layout is currently used by my application independent of the current Orientation of the mobile.