Skip to content

Commit

Permalink
Fixed child view won't render
Browse files Browse the repository at this point in the history
Added measureAndLayout when requestLayout called
  • Loading branch information
tlcheah2 committed Mar 30, 2017
1 parent 508403c commit 9a70c2b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions android/app/src/main/java/com/test/TestContainerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,21 @@ public boolean isViewFromObject(View view, Object object) {
this.addView(viewPager);
}

@Override
public void requestLayout() {
super.requestLayout();
post(measureAndLayout);
}

private final Runnable measureAndLayout = new Runnable() {
@Override
public void run() {
measure(
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
layout(getLeft(), getTop(), getRight(), getBottom());
}
};


}

0 comments on commit 9a70c2b

Please sign in to comment.