在ViewPager实例上调用setPageMargin(margin)后,当前片段(或页面)未正确重新定位。
我希望在setPageMargin()调用之后,left和right应该看起来完全一样。
MainActivity onCreate():
pager = (ViewPager) findViewById(R.id.view_pager);
pager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
public Fragment getItem(int position) {
return BlankFragment.newInstance("Hello " + position, "Test");
}
public int getCount() {
return 200;
}
});
切换按钮的onOptionsItemSelected()的MainActivity:
int margin;
if (toggleState) {
margin = 0;
toggleState = false;
} else {
margin = 100;
toggleState = true;
}
pager.setPageMargin(margin);
一个错误?