Skip to content
This repository
Browse code

max display height

  • Loading branch information...
commit a912d1f79509ff860a6ae0e394310f38ce80a153 1 parent 1633051
Will authored
1  res/values/styles.xml
@@ -21,6 +21,7 @@
21 21
     <dimen name="display_text_size">40sp</dimen>
22 22
     <dimen name="small_display_text_size">20sp</dimen>
23 23
     <dimen name="min_display_height">100dp</dimen>
  24
+    <dimen name="max_display_height">200dp</dimen>
24 25
     <dimen name="barHeight">25dp</dimen>
25 26
     <integer name="barHeight">25</integer>
26 27
 
19  src/com/android2/calculator3/view/ScrollableDisplay.java
@@ -8,10 +8,15 @@
8 8
 import android.view.View.OnLongClickListener;
9 9
 import android.widget.HorizontalScrollView;
10 10
 
  11
+import com.android2.calculator3.R;
  12
+
11 13
 public class ScrollableDisplay extends HorizontalScrollView implements OnLongClickListener {
  14
+    private int mMaxHeight;
  15
+
12 16
     public ScrollableDisplay(Context context, AttributeSet attrs) {
13 17
         super(context, attrs);
14 18
         addView(new AdvancedDisplay(context));
  19
+        setMaxHeight((int) getContext().getResources().getDimension(R.dimen.max_display_height));
15 20
         setOnLongClickListener(this);
16 21
     }
17 22
 
@@ -30,6 +35,20 @@ public boolean onTouchEvent(MotionEvent ev) {
30 35
         return false;
31 36
     }
32 37
 
  38
+    public void setMaxHeight(int maxHeight) {
  39
+        mMaxHeight = maxHeight;
  40
+    }
  41
+
  42
+    @Override
  43
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  44
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  45
+
  46
+        int width = getMeasuredWidth();
  47
+        int height = Math.min(getMeasuredHeight(), mMaxHeight);
  48
+
  49
+        setMeasuredDimension(width, height);
  50
+    }
  51
+
33 52
     private int getScrollRange() {
34 53
         int scrollRange = 0;
35 54
         if(getChildCount() > 0) {

0 notes on commit a912d1f

Please sign in to comment.
Something went wrong with that request. Please try again.