android - Nested Fragments within ViewPager have zero height and width -
i have activity
single fragment
inside of it. inside fragment have viewpager
pages fragments. makes paged fragments children of fragment inside activity. this:
activity | | fragment | (viewpager) | | | | fragment fragment
every often, seemingly @ random, fragments inside viewpager not display. looked @ view hierarchy in hierarchy viewer , noticed when happens child fragments (at bottom of picture) are in layout, root view of children has zero height , 0 width (as every view in hierarchy tree there down leaf views). viewpager
have height , width, fragments pages not.
if rotate device @ point, child fragments show up!
i'm @ loss why happening. adapter i'm using viewpager requires fragmentmanager
, , i'm using 1 fragment inside activity calling getchildfragmentmanager(). feel i'm doing i'm supposed do, not sure next on one.
update:
interestingly enough, if put code attaches adapter viewpager in runnable , post handler issue 100% reproducible. i.e.
class myfragment extends fragment { @override public void onactivitycreated(bundle b) { super.onactivitycreated(b); runpager = new runnable() { @override public void run() { viewpager.setadapter(adapter); } }; handler.post(runpager); } }
i figured out. if else runs this, make sure aren't manipulating ui components on background thread or weird things happen. in case doing bitmap manipulation on background thread rxjava, forgot line:
.observeon(androidschedulers.mainthread());
so when put bitmap in view in subscriber, on background thread. easy mistake make.
Comments
Post a Comment