Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set minimum width and height for views #25498

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
private static final String PROP_TRANSFORM = "transform";
private static final String PROP_ELEVATION = "elevation";
private static final String PROP_Z_INDEX = "zIndex";
private static final String PROP_MIN_WIDTH = ViewProps.MIN_WIDTH;
private static final String PROP_MIN_HEIGHT = ViewProps.MIN_HEIGHT;
private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
private static final String PROP_ACCESSIBILITY_LABEL = "accessibilityLabel";
private static final String PROP_ACCESSIBILITY_HINT = "accessibilityHint";
Expand Down Expand Up @@ -118,6 +120,16 @@ public void setZIndex(@Nonnull T view, float zIndex) {
}
}

@ReactProp(name = PROP_MIN_WIDTH)
public void setMinWidth(@Nonnull T view, int minWidth) {
view.setMinimumWidth((int) PixelUtil.toPixelFromDIP(minWidth));
}

@ReactProp(name = PROP_MIN_HEIGHT)
public void setMinHeight(@Nonnull T view, int minHeight) {
view.setMinimumHeight((int) PixelUtil.toPixelFromDIP(minHeight));
}

@ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE)
public void setRenderToHardwareTexture(@Nonnull T view, boolean useHWTexture) {
view.setLayerType(useHWTexture ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE, null);
Expand Down