summaryrefslogtreecommitdiff
path: root/core/java/android/widget/ImageView.java
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2010-11-10 18:00:52 -0800
committerJoe Onorato <joeo@google.com>2010-11-15 11:52:33 -0800
commitfd52b18d9bf3cd62c7a07058536e9f97db65beea (patch)
tree4a9e863387cf1bc2e9141581c5e416dc9f5789c7 /core/java/android/widget/ImageView.java
parent645336a7427afc2613df4648d7c4159ab2ec4b0e (diff)
The beginnings of the new status bar.
There is a lot of rough stuff still, but most of the functionality is here again. Change-Id: I4b1241e61270f1434e798481afa83634233ee670
Diffstat (limited to 'core/java/android/widget/ImageView.java')
-rw-r--r--core/java/android/widget/ImageView.java69
1 files changed, 64 insertions, 5 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index bad74d4e2ac2..555d993ab570 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -34,6 +34,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.RemotableViewMethod;
import android.view.View;
+import android.view.ViewDebug;
import android.widget.RemoteViews.RemoteView;
@@ -84,7 +85,8 @@ public class ImageView extends View {
private boolean mCropToPadding;
- private boolean mBaselineAligned = false;
+ private int mBaseline = -1;
+ private boolean mBaselineAlignBottom = false;
private static final ScaleType[] sScaleTypeArray = {
ScaleType.MATRIX,
@@ -118,9 +120,12 @@ public class ImageView extends View {
setImageDrawable(d);
}
- mBaselineAligned = a.getBoolean(
+ mBaselineAlignBottom = a.getBoolean(
com.android.internal.R.styleable.ImageView_baselineAlignBottom, false);
-
+
+ mBaseline = a.getDimensionPixelSize(
+ com.android.internal.R.styleable.ImageView_baseline, -1);
+
setAdjustViewBounds(
a.getBoolean(com.android.internal.R.styleable.ImageView_adjustViewBounds,
false));
@@ -180,7 +185,7 @@ public class ImageView extends View {
super.invalidateDrawable(dr);
}
}
-
+
@Override
protected boolean onSetAlpha(int alpha) {
if (getBackground() == null) {
@@ -878,9 +883,63 @@ public class ImageView extends View {
}
}
+ /**
+ * <p>Return the offset of the widget's text baseline from the widget's top
+ * boundary. </p>
+ *
+ * @return the offset of the baseline within the widget's bounds or -1
+ * if baseline alignment is not supported.
+ */
@Override
+ @ViewDebug.ExportedProperty(category = "layout")
public int getBaseline() {
- return mBaselineAligned ? getMeasuredHeight() : -1;
+ if (mBaselineAlignBottom) {
+ return getMeasuredHeight();
+ } else {
+ return mBaseline;
+ }
+ }
+
+ /**
+ * <p>Set the offset of the widget's text baseline from the widget's top
+ * boundary. This value is overridden by the {@link #setBaselineAlignBottom}
+ * property.</p>
+ *
+ * @param baseline The baseline to use, or -1 if none is to be provided.
+ *
+ * @see #setBaseline
+ * @attr ref android.R.styleable#ImageView_baseline
+ */
+ public void setBaseline(int baseline) {
+ if (mBaseline != baseline) {
+ mBaseline = baseline;
+ requestLayout();
+ }
+ }
+
+ /**
+ * Set whether to set the baseline of this view to the bottom of the view.
+ * Setting this value overrides any calls to setBaseline.
+ *
+ * @param aligned If true, the image view will be baseline aligned with
+ * based on its bottom edge.
+ *
+ * @attr ref android.R.styleable#ImageView_baselineAlignBottom
+ */
+ public void setBaselineAlignBottom(boolean aligned) {
+ if (mBaselineAlignBottom != aligned) {
+ mBaselineAlignBottom = aligned;
+ requestLayout();
+ }
+ }
+
+ /**
+ * Return whether this view's baseline will be considered the bottom of the view.
+ *
+ * @see #setBaselineAlignBottom(boolean)
+ */
+ public boolean getBaselineAlignBottom() {
+ return mBaselineAlignBottom;
}
/**