mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 09:30:10 +08:00
Apply FlatShadowNode padding to View
Summary: Any padding that a FlatShadowNode is assigned by React runtime should be translated to a backing Android View so it looks correct and lays out children accordingly. Reviewed By: sriramramani Differential Revision: D2756562
This commit is contained in:
committed by
Ahmed El-Helw
parent
dbe9cc333c
commit
312f04d2b7
@@ -21,6 +21,7 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
final ViewManager mViewManager;
|
||||
private final ReactShadowNode mReactShadowNode;
|
||||
private final boolean mNeedsCustomLayoutForChildren;
|
||||
private boolean mPaddingChanged = false;
|
||||
|
||||
/* package */ AndroidView(ViewManager viewManager) {
|
||||
mViewManager = viewManager;
|
||||
@@ -46,6 +47,14 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
return mNeedsCustomLayoutForChildren;
|
||||
}
|
||||
|
||||
/* package */ boolean isPaddingChanged() {
|
||||
return mPaddingChanged;
|
||||
}
|
||||
|
||||
/* package */ void resetPaddingChanged() {
|
||||
mPaddingChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int backgroundColor) {
|
||||
// suppress, this is handled by a ViewManager
|
||||
@@ -72,4 +81,12 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
super.addChildAt(child, i);
|
||||
((FlatShadowNode) child).forceMountToView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPadding(int spacingType, float padding) {
|
||||
if (getPadding().set(spacingType, padding)) {
|
||||
mPaddingChanged = true;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user