I want to display 6 images in the form of grid as follows.
in portrait orientation,2 coumns, 3 rows and in landscare orientation 3 columns, 2 rows
By using Android GridView and by defining different grid layouts in layout-port and layout-land directories I was able to achieve this effect.
Later as per my activity requirement, I added one parameter in manifest.xml that is
android:configChanges = "mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale|screenSize"`
to stop my activity to recreate once screen orientation changes.
After adding this parameter, my grid view is not behaving in expected way. It sometimes shows 1 column, sometimes 2 columns, and sometimes 3 columns.
I am placing gridView.setNumberOfColumns(2) or gridView.setNumberOfColumns(3) methods in the get view method of my grid adapter depending on orientation of the device.
Please help me to achieve this effect without removing the android:configChanges parameter in Manifest.xml