int width = params.width + 20; int height = params.height + 240; view.setLayoutParams(new ViewGroup.LayoutParams(width,height));我基本上想在视图分页器中展开当前视图。
这是我尝试的但是这不会改变当前视图上的任何内容。
private ViewPager.OnPageChangeListener mPageListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
View view = mViewPager.findViewWithTag(position);
if (view == null)
return;
view.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewGroup.LayoutParams params = view.getLayoutParams();
int width = params.width + 20;
int height = params.height + 240;
view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
}
@Override
public void onPageScrollStateChanged(int state) {
}
};
提前致谢:)
答案 0 :(得分:0)
使用:
view.setLayoutParams(new LayoutParams(width, height));