Fix children of AndroidView not being re-laid out after they call requestLayout

Summary:
In ReactNative, we are fully controlling layout of all the Views, not allowing Android to layout anything for us. This is done by making onLayout() of the top-level View in the hierarchy to be empty. This works fine because we explicitly call measure/layout for all the Views when they need to be re-measured or re-laid out. There is however one case where this doesn't happen automatically: some Android Views such as DrawerLayout or ActionBar have children that don't have shadow nodes associated with them (such as a title in ActionBar). This results in situations where children of AndroidView will call requestLayout but they will never get relaid out, because shadow hierarchy doesn't know about them. Example: ActionBar has a seTitle method that will internally call TextView.setTitle() and that TextView will call requestLayout because its size may have changed. However, that TextView will never be remeasured or relaid out.

This diff is fixing it by keeping track of everyone who called requestLayout. Then, at the end of the update loop we go over the list a manually remeasure and relayout those Views.

Not a huge fan of how this is implemented (there MUST be a better way) but this works with least efforts. I'll see if I can improve it later.

Reviewed By: ahmedre

Differential Revision: D2757485
This commit is contained in:
Denis Koroskin
2015-12-16 14:57:07 -08:00
committed by Ahmed El-Helw
parent ad65b2a9e1
commit 529390b87c
3 changed files with 52 additions and 1 deletions

View File

@@ -84,6 +84,8 @@ import com.facebook.react.uimanager.CatalystStylesDiffMap;
mOperationsQueue.enqueueDropViews(collectViewTags(mViewsToDrop));
mViewsToDrop.clear();
}
mOperationsQueue.enqueueProcessLayoutRequests();
}
/**