試試這個,
你應該使用ViewPager與Tablayout使這種在這種情況下不發生問題......
請參考以下鏈接,
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return new TabFragment(); // Which Fragment should be dislpayed by the viewpager for the given position
// In my case we are showing up only one fragment in all the three tabs so we are
// not worrying about the position and just returning the TabFragment
}
@Override
public int getCount() {
return 3; // As there are only 3 Tabs
}
}
http://www.android4devs.com/2015/12/tab-layout-material-design-support.html
我希望它能幫助你...