I know the question is a bit outdated, but my answer may help someone else, since your question and Colin's answer helped me.
I have exactly the same problem as you. And there are two solutions for this. First you need to make sure that your ViewPager has * layout_width * and * layout_height * set to * match_parent *, and this view hierarchy is organized in such a way that Android does not come to the conclusion that it needs to redeploy any parent ViewPager layouts. For example, let's say you have a RelativeLayout with two views of fixed sizes, one below the other and a ViewPager under the second view. In this case, any change in the ViewPager will apply to the parent layout. However, if you place these two types of fixed size and ViewPager in LinearLayout, this does not happen, the layout request will not extend beyond the ViewPager. What's even better, a layout request on one page of the ViewPager will not extend to other pages.
The second solution (actually this is the second part of the solution) is your FrameLayout, but it has changed as follows:
public class LayoutStopperFrameLayout extends FrameLayout { private boolean doLayout; public LayoutStopperFrameLayout(Context context) { super(context); doLayout = true; } public LayoutStopperFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); doLayout = true; } public LayoutStopperFrameLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); doLayout = true; } public void setPropagateRequestLayout(boolean doLayout) { this.doLayout = doLayout; } @Override public void requestLayout() { if (doLayout) {
In my application, I call setPropagateRequestLayout () on the Fragment onStart and onStop methods to enable or disable layout requests.
anqe1ki11er
source share