From fd52b18d9bf3cd62c7a07058536e9f97db65beea Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Wed, 10 Nov 2010 18:00:52 -0800 Subject: 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 --- core/java/android/widget/ImageView.java | 69 ++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 5 deletions(-) (limited to 'core/java/android/widget/ImageView.java') 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 { } } + /** + *

Return the offset of the widget's text baseline from the widget's top + * boundary.

+ * + * @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; + } + } + + /** + *

Set the offset of the widget's text baseline from the widget's top + * boundary. This value is overridden by the {@link #setBaselineAlignBottom} + * property.

+ * + * @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; } /** -- cgit v1.2.3