I need to show 2 columns in RecyclerView
when the orientation is portrait and 4 columns when orientation is land
. It works correct on the emulator.
It's RecyclerView
in portrait orientation.
Turning the emulator:
As you can see, there is refresh button. And after clicking on it we see 4 columns on screen:
But when I run the project on my mobile phone, there is no refresh button and I see 2 columns in land orientation.
Here's a part of my code:
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
previewImages.setLayoutManager(new GridLayoutManager(this, 4));
}
else {
previewImages.setLayoutManager(new GridLayoutManager(this, 2));
}
}
And I added this line to manifest:
android:configChanges="orientation"
So, what's the problem and how can I solve it?