Oh my gosh i can't believe i spent a whole day yesterday figuring this out. I was supposed to set the
mViewPager.setOffscreenPageLimit(numOfFragments);
In the main activity where i hold the viewPager. Therefore the fragments are kept in memory for some time i guess and the layouts don't lose their size adjustment in code or any other interaction of that sort. I just wanted to point out that you should pay attention to details like this and use this line of code any time you are implementing an action bar with tab changing.