TabStacker icon indicating copy to clipboard operation
TabStacker copied to clipboard

change recyclerview type on rotation

Open pishguy opened this issue 6 years ago • 0 comments

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?

pishguy avatar Jan 06 '19 19:01 pishguy