OSDN Git Service

Support setting the bounds on a ProgressOverlay.
authorErin Dahlgren <edahlgren@google.com>
Tue, 25 Feb 2014 20:06:40 +0000 (12:06 -0800)
committerErin Dahlgren <edahlgren@google.com>
Tue, 25 Feb 2014 20:06:40 +0000 (12:06 -0800)
Bug: 12650252
Change-Id: Ic91a4716c3dafa9ca5133c3f0eff1a56424d2faa

src/com/android/camera/ui/ProgressOverlay.java

index 5357bb8..c566c79 100644 (file)
@@ -18,7 +18,9 @@ package com.android.camera.ui;
 
 import android.content.Context;
 import android.graphics.Canvas;
+import android.graphics.RectF;
 import android.view.View;
+import android.view.ViewGroup;
 import android.util.AttributeSet;
 
 /**
@@ -48,6 +50,19 @@ public class ProgressOverlay extends View {
         }
     }
 
+    /**
+     * Reposition the view within a given set of bounds, defined by a
+     * {@link android.graphics.RectF}.
+     */
+    public void setBounds(RectF area) {
+        if (area.width() > 0 && area.height() > 0) {
+            ViewGroup.LayoutParams params = getLayoutParams();
+            params.width = (int) area.width();
+            params.height= (int) area.height();
+            setLayoutParams(params);
+        }
+    }
+
     @Override
     public void onDraw(Canvas canvas) {
         mProgressRenderer.onDraw(canvas, mCenterX, mCenterY);