TabStacker
TabStacker copied to clipboard
change recyclerview type on rotation
i have some code to detect orientation and change recylerview type, for example:
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
// Choose between one, two or three elements per row
if (dpWidth > 720 && getResources().getConfiguration().orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
instagram_feeds.setLayoutManager(new GridLayoutManager(context, 3, LinearLayoutManager.VERTICAL, false));
} else if (dpWidth > 520) {
instagram_feeds.setLayoutManager(new GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL, false));
} else {
instagram_feeds.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
}
after rotation activity and fragment i can't use this code witch that inside onCreateView
how can i resolve this problem?