Skip to content

Commit 1473b8b

Browse files
committed
minHeight
1 parent c97480f commit 1473b8b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

android/titanium/src/java/org/appcelerator/titanium/view/TiCompositeLayout.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public enum LayoutArrangement {
7070
private int viewMinWidth = -1;
7171
private int viewMaxWidth = -1;
7272
private int viewMaxHeight = -1;
73+
private int viewMinHeight = -1;
7374
int[] horizontal = new int[2];
7475
int[] vertical = new int[2];
7576
/**
@@ -653,6 +654,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
653654
if (viewMaxHeight != -1 && measuredHeight > viewMaxHeight) {
654655
measuredHeight = viewMaxHeight;
655656
}
657+
if (viewMinHeight != -1 && measuredHeight < viewMinHeight) {
658+
measuredHeight = viewMinHeight;
659+
}
656660
setMeasuredDimension(measuredWidth, measuredHeight);
657661
}
658662

@@ -1262,6 +1266,10 @@ public void setMaxHeight(Integer value)
12621266
{
12631267
viewMaxHeight = value;
12641268
}
1269+
public void setMinHeight(Integer value)
1270+
{
1271+
viewMinHeight = value;
1272+
}
12651273

12661274
public void setEnableHorizontalWrap(boolean enable)
12671275
{

android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public abstract class TiUIView implements KrollProxyListener, OnFocusChangeListe
113113
protected TiBackgroundDrawable background;
114114
private int minWidth = -1;
115115
private int maxWidth = -1;
116+
private int minHeight = -1;
116117
private int maxHeight = -1;
117118

118119
public TiBackgroundDrawable getBackground()
@@ -793,6 +794,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
793794
setMinWidth(newValue, hasBorder(proxy.getProperties()));
794795
} else if (key.equals("maxHeight")) {
795796
setMaxHeight(newValue, hasBorder(proxy.getProperties()));
797+
} else if (key.equals("minHeight")) {
798+
setMinHeight(newValue, hasBorder(proxy.getProperties()));
796799
} else if (key.equals(TiC.PROPERTY_VISIBLE)) {
797800
newValue = (newValue == null) ? false : newValue;
798801
this.setVisibility(TiConvert.toBoolean(newValue) ? View.VISIBLE : View.INVISIBLE);
@@ -1072,6 +1075,9 @@ public void processProperties(KrollDict d)
10721075
if (d.containsKey("maxHeight")) {
10731076
setMaxHeight(d.get("maxHeight"), hasBorder(d));
10741077
}
1078+
if (d.containsKey("minHeight")) {
1079+
setMinHeight(d.get("minHeight"), hasBorder(d));
1080+
}
10751081
initializeBorder(d, bgColor);
10761082

10771083
if (d.containsKey(TiC.PROPERTY_OPACITY) && !nativeViewNull) {
@@ -1205,6 +1211,20 @@ private void setMaxHeight(Object value, Boolean hasBorder)
12051211
Log.w(TAG, "You can only use maxHeight for Views without borders");
12061212
}
12071213
}
1214+
private void setMinHeight(Object value, Boolean hasBorder)
1215+
{
1216+
minHeight = -1;
1217+
if (value != null) {
1218+
minHeight = TiConvert.toTiDimension(TiConvert.toInt(value),
1219+
TiDimension.TYPE_HEIGHT).getAsPixels(nativeView);
1220+
}
1221+
1222+
if (!hasBorder) {
1223+
((TiCompositeLayout) nativeView).setMinHeight(minHeight);
1224+
} else {
1225+
Log.w(TAG, "You can only use maxHeight for Views without borders");
1226+
}
1227+
}
12081228

12091229
private void setAnchor(HashMap point)
12101230
{

0 commit comments

Comments
 (0)