diff options
| author | Gilles Debunne <debunne@google.com> | 2012-04-30 19:26:19 -0700 |
|---|---|---|
| committer | Gilles Debunne <debunne@google.com> | 2012-04-30 21:08:41 -0700 |
| commit | f03acef0ab614fbd69eee606bb60434f9659259f (patch) | |
| tree | 629c4b262bc3ffd238772a363ce765c1841bfa36 /core/java/android/widget/TextView.java | |
| parent | 2f87014ea2f177e715032b07004d05e2549a63a8 (diff) | |
API fix in TextView
Bug 6104140
Change-Id: I44af54ac7c194335a649e5878ff47dc894fa46fe
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 331 |
1 files changed, 322 insertions, 9 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b2ad25dd22ec..ba814d325bd1 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -1250,6 +1250,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * * Note: The content of the return value should not be modified. If you want * a modifiable one, you should make your own copy first. + * + * @attr ref android.R.styleable#TextView_text */ @ViewDebug.CapturedViewProperty public CharSequence getText() { @@ -1294,6 +1296,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * @return the current key listener for this TextView. * This will frequently be null for non-EditText TextViews. + * + * @attr ref android.R.styleable#TextView_numeric + * @attr ref android.R.styleable#TextView_digits + * @attr ref android.R.styleable#TextView_phoneNumber + * @attr ref android.R.styleable#TextView_inputMethod + * @attr ref android.R.styleable#TextView_capitalize + * @attr ref android.R.styleable#TextView_autoText */ public final KeyListener getKeyListener() { return mEditor == null ? null : mEditor.mKeyListener; @@ -1408,6 +1417,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * @return the current transformation method for this TextView. * This will frequently be null except for single-line and password * fields. + * + * @attr ref android.R.styleable#TextView_password + * @attr ref android.R.styleable#TextView_singleLine */ public final TransformationMethod getTransformationMethod() { return mTransformation; @@ -1988,6 +2000,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Returns drawables for the left, top, right, and bottom borders. + * + * @attr ref android.R.styleable#TextView_drawableLeft + * @attr ref android.R.styleable#TextView_drawableTop + * @attr ref android.R.styleable#TextView_drawableRight + * @attr ref android.R.styleable#TextView_drawableBottom */ public Drawable[] getCompoundDrawables() { final Drawables dr = mDrawables; @@ -2002,6 +2019,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Returns drawables for the start, top, end, and bottom borders. + * + * @attr ref android.R.styleable#TextView_drawableStart + * @attr ref android.R.styleable#TextView_drawableTop + * @attr ref android.R.styleable#TextView_drawableEnd + * @attr ref android.R.styleable#TextView_drawableBottom */ public Drawable[] getCompoundDrawablesRelative() { final Drawables dr = mDrawables; @@ -2040,6 +2062,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Returns the padding between the compound drawables and the text. + * + * @attr ref android.R.styleable#TextView_drawablePadding */ public int getCompoundDrawablePadding() { final Drawables dr = mDrawables; @@ -2235,6 +2259,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * {@link #setTypeface(Typeface, int)} to get the appearance * that you actually want. * + * @see #getTypeface() + * * @attr ref android.R.styleable#TextView_typeface * @attr ref android.R.styleable#TextView_textStyle */ @@ -2253,6 +2279,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * @return the current typeface and style in which the text is being * displayed. + * + * @see #setTypeface(Typeface) + * + * @attr ref android.R.styleable#TextView_typeface + * @attr ref android.R.styleable#TextView_textStyle */ public Typeface getTypeface() { return mTextPaint.getTypeface(); @@ -2262,6 +2293,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Sets the text color for all the states (normal, selected, * focused) to be this color. * + * @see #setTextColor(ColorStateList) + * @see #getTextColors() + * * @attr ref android.R.styleable#TextView_textColor */ @android.view.RemotableViewMethod @@ -2273,6 +2307,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Sets the text color. * + * @see #setTextColor(int) + * @see #getTextColors() + * @see #setHintTextColor(ColorStateList) + * @see #setLinkTextColor(ColorStateList) + * * @attr ref android.R.styleable#TextView_textColor */ public void setTextColor(ColorStateList colors) { @@ -2285,9 +2324,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** - * Return the set of text colors. + * Gets the text colors for the different states (normal, selected, focused) of the TextView. + * + * @see #setTextColor(ColorStateList) + * @see #setTextColor(int) * - * @return Returns the set of text colors. + * @attr ref android.R.styleable#TextView_textColor */ public final ColorStateList getTextColors() { return mTextColor; @@ -2316,6 +2358,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the color used to display the selection highlight + * + * @see #setHighlightColor(int) + * + * @attr ref android.R.styleable#TextView_textColorHighlight + */ + public int getHighlightColor() { + return mHighlightColor; + } + + /** * Sets whether the soft input method will be made visible when this * TextView gets focused. The default is true. * @hide @@ -2358,6 +2411,52 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * Gets the radius of the shadow layer. + * + * @return the radius of the shadow layer. If 0, the shadow layer is not visible + * + * @see #setShadowLayer(float, float, float, int) + * + * @attr ref android.R.styleable#TextView_shadowRadius + */ + public float getShadowRadius() { + return mShadowRadius; + } + + /** + * @return the horizontal offset of the shadow layer + * + * @see #setShadowLayer(float, float, float, int) + * + * @attr ref android.R.styleable#TextView_shadowDx + */ + public float getShadowDx() { + return mShadowDx; + } + + /** + * @return the vertical offset of the shadow layer + * + * @see #setShadowLayer(float, float, float, int) + * + * @attr ref android.R.styleable#TextView_shadowDy + */ + public float getShadowDy() { + return mShadowDy; + } + + /** + * @return the color of the shadow layer + * + * @see #setShadowLayer(float, float, float, int) + * + * @attr ref android.R.styleable#TextView_shadowColor + */ + public int getShadowColor() { + return mTextPaint.shadowColor; + } + + /** * @return the base paint used for the text. Please use this only to * consult the Paint's properties and not to change them. */ @@ -2418,7 +2517,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** - * Sets the color of the hint text. + * Sets the color of the hint text for all the states (disabled, focussed, selected...) of this + * TextView. + * + * @see #setHintTextColor(ColorStateList) + * @see #getHintTextColors() + * @see #setTextColor(int) * * @attr ref android.R.styleable#TextView_textColorHint */ @@ -2431,6 +2535,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Sets the color of the hint text. * + * @see #getHintTextColors() + * @see #setHintTextColor(int) + * @see #setTextColor(ColorStateList) + * @see #setLinkTextColor(ColorStateList) + * * @attr ref android.R.styleable#TextView_textColorHint */ public final void setHintTextColor(ColorStateList colors) { @@ -2439,9 +2548,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** - * <p>Return the color used to paint the hint text.</p> + * @return the color of the hint text, for the different states of this TextView. + * + * @see #setHintTextColor(ColorStateList) + * @see #setHintTextColor(int) + * @see #setTextColor(ColorStateList) + * @see #setLinkTextColor(ColorStateList) * - * @return Returns the list of hint text colors. + * @attr ref android.R.styleable#TextView_textColorHint */ public final ColorStateList getHintTextColors() { return mHintTextColor; @@ -2459,6 +2573,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Sets the color of links in the text. * + * @see #setLinkTextColor(ColorStateList) + * @see #getLinkTextColors() + * * @attr ref android.R.styleable#TextView_textColorLink */ @android.view.RemotableViewMethod @@ -2470,6 +2587,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Sets the color of links in the text. * + * @see #setLinkTextColor(int) + * @see #getLinkTextColors() + * @see #setTextColor(ColorStateList) + * @see #setHintTextColor(ColorStateList) + * * @attr ref android.R.styleable#TextView_textColorLink */ public final void setLinkTextColor(ColorStateList colors) { @@ -2478,9 +2600,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** - * <p>Returns the color used to paint links in the text.</p> + * @return the list of colors used to paint the links in the text, for the different states of + * this TextView + * + * @see #setLinkTextColor(ColorStateList) + * @see #setLinkTextColor(int) * - * @return Returns the list of link text colors. + * @attr ref android.R.styleable#TextView_textColorLink */ public final ColorStateList getLinkTextColors() { return mLinkTextColor; @@ -2598,6 +2724,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Setting this value overrides any other (minimum) height setting. A single line TextView will * set this value to 1. * + * @see #getMinLines() + * * @attr ref android.R.styleable#TextView_minLines */ @android.view.RemotableViewMethod @@ -2610,6 +2738,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the minimum number of lines displayed in this TextView, or -1 if the minimum + * height was set in pixels instead using {@link #setMinHeight(int) or #setHeight(int)}. + * + * @see #setMinLines(int) + * + * @attr ref android.R.styleable#TextView_minLines + */ + public int getMinLines() { + return mMinMode == LINES ? mMinimum : -1; + } + + /** * Makes the TextView at least this many pixels tall. * * Setting this value overrides any other (minimum) number of lines setting. @@ -2626,6 +2766,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the minimum height of this TextView expressed in pixels, or -1 if the minimum + * height was set in number of lines instead using {@link #setMinLines(int) or #setLines(int)}. + * + * @see #setMinHeight(int) + * + * @attr ref android.R.styleable#TextView_minHeight + */ + public int getMinHeight() { + return mMinMode == PIXELS ? mMinimum : -1; + } + + /** * Makes the TextView at most this many lines tall. * * Setting this value overrides any other (maximum) height setting. @@ -2642,6 +2794,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the maximum number of lines displayed in this TextView, or -1 if the maximum + * height was set in pixels instead using {@link #setMaxHeight(int) or #setHeight(int)}. + * + * @see #setMaxLines(int) + * + * @attr ref android.R.styleable#TextView_maxLines + */ + public int getMaxLines() { + return mMaxMode == LINES ? mMaximum : -1; + } + + /** * Makes the TextView at most this many pixels tall. This option is mutually exclusive with the * {@link #setMaxLines(int)} method. * @@ -2659,6 +2823,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the maximum height of this TextView expressed in pixels, or -1 if the maximum + * height was set in number of lines instead using {@link #setMaxLines(int) or #setLines(int)}. + * + * @see #setMaxHeight(int) + * + * @attr ref android.R.styleable#TextView_maxHeight + */ + public int getMaxHeight() { + return mMaxMode == PIXELS ? mMaximum : -1; + } + + /** * Makes the TextView exactly this many lines tall. * * Note that setting this value overrides any other (minimum / maximum) number of lines or @@ -2709,6 +2885,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the minimum width of the TextView, expressed in ems or -1 if the minimum width + * was set in pixels instead (using {@link #setMinWidth(int)} or {@link #setWidth(int)}). + * + * @see #setMinEms(int) + * @see #setEms(int) + * + * @attr ref android.R.styleable#TextView_minEms + */ + public int getMinEms() { + return mMinWidthMode == EMS ? mMinWidth : -1; + } + + /** * Makes the TextView at least this many pixels wide * * @attr ref android.R.styleable#TextView_minWidth @@ -2723,6 +2912,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the minimum width of the TextView, in pixels or -1 if the minimum width + * was set in ems instead (using {@link #setMinEms(int)} or {@link #setEms(int)}). + * + * @see #setMinWidth(int) + * @see #setWidth(int) + * + * @attr ref android.R.styleable#TextView_minWidth + */ + public int getMinWidth() { + return mMinWidthMode == PIXELS ? mMinWidth : -1; + } + + /** * Makes the TextView at most this many ems wide * * @attr ref android.R.styleable#TextView_maxEms @@ -2737,6 +2939,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the maximum width of the TextView, expressed in ems or -1 if the maximum width + * was set in pixels instead (using {@link #setMaxWidth(int)} or {@link #setWidth(int)}). + * + * @see #setMaxEms(int) + * @see #setEms(int) + * + * @attr ref android.R.styleable#TextView_maxEms + */ + public int getMaxEms() { + return mMaxWidthMode == EMS ? mMaxWidth : -1; + } + + /** * Makes the TextView at most this many pixels wide * * @attr ref android.R.styleable#TextView_maxWidth @@ -2751,8 +2966,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * @return the maximum width of the TextView, in pixels or -1 if the maximum width + * was set in ems instead (using {@link #setMaxEms(int)} or {@link #setEms(int)}). + * + * @see #setMaxWidth(int) + * @see #setWidth(int) + * + * @attr ref android.R.styleable#TextView_maxWidth + */ + public int getMaxWidth() { + return mMaxWidthMode == PIXELS ? mMaxWidth : -1; + } + + /** * Makes the TextView exactly this many ems wide * + * @see #setMaxEms(int) + * @see #setMinEms(int) + * @see #getMinEms() + * @see #getMaxEms() + * * @attr ref android.R.styleable#TextView_ems */ @android.view.RemotableViewMethod @@ -2769,6 +3002,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * You could do the same thing by specifying this number in the * LayoutParams. * + * @see #setMaxWidth(int) + * @see #setMinWidth(int) + * @see #getMinWidth() + * @see #getMaxWidth() + * * @attr ref android.R.styleable#TextView_width */ @android.view.RemotableViewMethod @@ -2780,7 +3018,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener invalidate(); } - /** * Sets line spacing for this TextView. Each line will have its height * multiplied by <code>mult</code> and have <code>add</code> added to it. @@ -2802,6 +3039,34 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * Gets the line spacing multiplier + * + * @return the value by which each line's height is multiplied to get its actual height. + * + * @see #setLineSpacing(float, float) + * @see #getLineSpacingExtra() + * + * @attr ref android.R.styleable#TextView_lineSpacingMultiplier + */ + public float getLineSpacingMultiplier() { + return mSpacingMult; + } + + /** + * Gets the line spacing extra space + * + * @return the extra space that is added to the height of each lines of this TextView. + * + * @see #setLineSpacing(float, float) + * @see #getLineSpacingMultiplier() + * + * @attr ref android.R.styleable#TextView_lineSpacingExtra + */ + public float getLineSpacingExtra() { + return mSpacingAdd; + } + + /** * Convenience method: Append the specified text to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was * not already editable. @@ -3883,6 +4148,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Returns the current list of input filters. + * + * @attr ref android.R.styleable#TextView_maxLength */ public InputFilter[] getFilters() { return mFilters; @@ -5639,6 +5906,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * room for accents that go above the normal ascent and descent. * The default is true. * + * @see #getIncludeFontPadding() + * * @attr ref android.R.styleable#TextView_includeFontPadding */ public void setIncludeFontPadding(boolean includepad) { @@ -5653,6 +5922,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } + /** + * Gets whether the TextView includes extra top and bottom padding to make + * room for accents that go above the normal ascent and descent. + * + * @see #setIncludeFontPadding(boolean) + * + * @attr ref android.R.styleable#TextView_includeFontPadding + */ + public boolean getIncludeFontPadding() { + return mIncludePad; + } + private static final BoringLayout.Metrics UNKNOWN_BORING = new BoringLayout.Metrics(); @Override @@ -6504,6 +6785,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Sets how many times to repeat the marquee animation. Only applied if the * TextView has marquee enabled. Set to -1 to repeat indefinitely. * + * @see #getMarqueeRepeatLimit() + * * @attr ref android.R.styleable#TextView_marqueeRepeatLimit */ public void setMarqueeRepeatLimit(int marqueeLimit) { @@ -6511,6 +6794,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * Gets the number of times the marquee animation is repeated. Only meaningful if the + * TextView has marquee enabled. + * + * @return the number of times the marquee animation is repeated. -1 if the animation + * repeats indefinitely + * + * @see #setMarqueeRepeatLimit(int) + * + * @attr ref android.R.styleable#TextView_marqueeRepeatLimit + */ + public int getMarqueeRepeatLimit() { + return mMarqueeRepeatLimit; + } + + /** * Returns where, if anywhere, words that are longer than the view * is wide should be ellipsized. */ @@ -6536,7 +6834,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** - * Set whether the cursor is visible. The default is true. + * Set whether the cursor is visible. The default is true. Note that this property only + * makes sense for editable TextView. + * + * @see #isCursorVisible() * * @attr ref android.R.styleable#TextView_cursorVisible */ @@ -6555,6 +6856,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } + /** + * @return whether or not the cursor is visible (assuming this TextView is editable) + * + * @see #setCursorVisible(boolean) + * + * @attr ref android.R.styleable#TextView_cursorVisible + */ + public boolean isCursorVisible() { + // true is the default value + return mEditor == null ? true : mEditor.mCursorVisible; + } + private boolean canMarquee() { int width = (mRight - mLeft - getCompoundPaddingLeft() - getCompoundPaddingRight()); return width > 0 && (mLayout.getLineWidth(0) > width || |
