java.lang.Object | |||
android.view.View | Drawable.Callback KeyEvent.Callback | ||
android.widget.TextView | ViewTreeObserver.OnPreDrawListener |
Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing.
XML attributes
See TextView Attributes, View Attributes
Attribute name | Related methods | |
---|---|---|
android:autoLink | setAutoLinkMask(int) |
Controls whether links such as urls and email addresses are automatically found and converted to clickable links. |
android:autoText | setKeyListener(KeyListener) |
If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. |
android:bufferType | setText(CharSequence,TextView.BufferType) |
Determines what the minimum type that getText() will return. |
android:capitalize | setKeyListener(KeyListener) |
If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. |
android:cursorVisible | setCursorVisible(boolean) |
Makes the cursor visible (the default) or invisible
Must be a boolean value, either " |
android:digits | setKeyListener(KeyListener) |
If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. |
android:drawableBottom | setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable) |
The drawable to be drawn below the text. |
android:drawableLeft | setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable) |
The drawable to be drawn to the left of the text. |
android:drawablePadding | setCompoundDrawablePadding(int) |
The padding between the drawables and the text. |
android:drawableRight | setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable) |
The drawable to be drawn to the right of the text. |
android:drawableTop | setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable) |
The drawable to be drawn above the text. |
android:editable | If set, specifies that this TextView has an input method. | |
android:ellipsize | setEllipsize(TextUtils.TruncateAt) |
If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. |
android:ems | setEms(int) |
Makes the TextView be exactly this many ems wide
Must be an integer value, such as " |
android:freezesText | setFreezesText(boolean) |
If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. |
android:gravity | setGravity(int) |
Vertical gravity (top, center_vertical, bottom) when the text is smaller than the view. |
android:height | setHeight(int) |
Makes the TextView be exactly this many pixels tall. |
android:hint | setHint(int) |
Hint text to display when the text is empty. |
android:includeFontPadding | setIncludeFontPadding(boolean) |
Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. |
android:inputMethod | setKeyListener(KeyListener) |
If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). |
android:lines | setLines(int) |
Makes the TextView be exactly this many lines tall
Must be an integer value, such as " |
android:linksClickable | setLinksClickable(boolean) |
If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found. |
android:maxEms | setMaxEms(int) |
Makes the TextView be at most this many ems wide
Must be an integer value, such as " |
android:maxHeight | setMaxHeight(int) |
Makes the TextView be at most this many pixels tall
Must be a dimension value, which is a floating point number appended with a unit such as " |
android:maxLength | setFilters(InputFilter) |
Set an input filter to constrain the text length to the specified number. |
android:maxLines | setMaxLines(int) |
Makes the TextView be at most this many lines tall
Must be an integer value, such as " |
android:maxWidth | setMaxWidth(int) |
Makes the TextView be at most this many pixels wide
Must be a dimension value, which is a floating point number appended with a unit such as " |
android:minEms | setMinEms(int) |
Makes the TextView be at least this many ems wide
Must be an integer value, such as " |
android:minHeight | setMinHeight(int) |
Makes the TextView be at least this many pixels tall
Must be a dimension value, which is a floating point number appended with a unit such as " |
android:minLines | setMinLines(int) |
Makes the TextView be at least this many lines tall
Must be an integer value, such as " |
android:minWidth | setMinWidth(int) |
Makes the TextView be at least this many pixels wide
Must be a dimension value, which is a floating point number appended with a unit such as " |
android:numeric | setKeyListener(KeyListener) |
If set, specifies that this TextView has a numeric input method. |
android:password | setTransformationMethod(TransformationMethod) |
Whether the characters of the field are displayed as password dots instead of themselves. |
android:phoneNumber | setKeyListener(KeyListener) |
If set, specifies that this TextView has a phone number input method. |
android:scrollHorizontally | setHorizontallyScrolling(boolean) |
Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). |
android:selectAllOnFocus | setSelectAllOnFocus(boolean) |
If the text is selectable, select it all when the view takes focus instead of moving the cursor to the start or end. |
android:shadowColor | setShadowLayer(float,float,float,int) |
Place a shadow of the specified color behind the text. |
android:shadowDx | setShadowLayer(float,float,float,int) |
Horizontal offset of the shadow. |
android:shadowDy | setShadowLayer(float,float,float,int) |
Vertical offset of the shadow. |
android:shadowRadius | setShadowLayer(float,float,float,int) |
Radius of the shadow. |
android:singleLine | setTransformationMethod(TransformationMethod) |
Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. |
android:text | setText(CharSequence) |
Text to display. |
android:textColor | setTextColor(ColorStateList) |
Text color. |
android:textColorHighlight | setHighlightColor(int) |
Color of the text selection highlight. |
android:textColorHint | setHintTextColor(int) |
Color of the hint text. |
android:textColorLink | setLinkTextColor(int) |
Text color for links. |
android:textScaleX | setTextScaleX(float) |
Sets the horizontal scaling factor for the text
Must be a floating point value, such as " |
android:textSize | setTextSize(float) |
Size of the text. |
android:textStyle | setTypeface(Typeface) |
Style (bold, italic, bolditalic) for the text. |
android:typeface | setTypeface(Typeface) |
Typeface (normal, sans, serif, monospace) for the text. |
android:width | setWidth(int) |
Makes the TextView be exactly this many pixels wide. |
TextView(Context context) | ||||||
TextView(Context context, AttributeSet attrs) | ||||||
TextView(Context context, AttributeSet attrs, int defStyle) |
void | addTextChangedListener(TextWatcher watcher) | |||||
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes. | ||||||
final | void | append(CharSequence text) | ||||
Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable. | ||||||
void | append(CharSequence text, int start, int end) | |||||
Convenience method: Append the specified text slice to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable. | ||||||
void | computeScroll() | |||||
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. | ||||||
void | debug(int depth) | |||||
Prints information about this view in the log output, with the tag VIEW_LOG_TAG. | ||||||
final | int | getAutoLinkMask() | ||||
Gets the autolink mask of the text. | ||||||
int | getBaseline() | |||||
Return the offset of the widget's text baseline from the widget's top boundary. |
||||||
int | getCompoundDrawablePadding() | |||||
Returns the padding between the compound drawables and the text. | ||||||
Drawable[] | getCompoundDrawables() | |||||
Returns drawables for the left, top, right, and bottom borders. | ||||||
int | getCompoundPaddingBottom() | |||||
Returns the bottom padding of the view, plus space for the bottom Drawable if any. | ||||||
int | getCompoundPaddingLeft() | |||||
Returns the left padding of the view, plus space for the left Drawable if any. | ||||||
int | getCompoundPaddingRight() | |||||
Returns the right padding of the view, plus space for the right Drawable if any. | ||||||
int | getCompoundPaddingTop() | |||||
Returns the top padding of the view, plus space for the top Drawable if any. | ||||||
final | int | getCurrentHintTextColor() | ||||
Return the current color selected to paint the hint text. |
||||||
final | int | getCurrentTextColor() | ||||
Return the current color selected for normal text. |
||||||
TextUtils.TruncateAt | getEllipsize() | |||||
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized. | ||||||
CharSequence | getError() | |||||
Returns the error message that was set to be displayed with
setError(CharSequence), or null if no error was set
or if it the error was cleared by the widget after user input. |
||||||
int | getExtendedPaddingBottom() | |||||
Returns the extended bottom padding of the view, including both the bottom Drawable if any and any extra space to keep more than maxLines of text from showing. | ||||||
int | getExtendedPaddingTop() | |||||
Returns the extended top padding of the view, including both the top Drawable if any and any extra space to keep more than maxLines of text from showing. | ||||||
InputFilter[] | getFilters() | |||||
Returns the current list of input filters. | ||||||
void | getFocusedRect(Rect r) | |||||
When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method. | ||||||
boolean | getFreezesText() | |||||
Return whether this text view is including its entire text contents in frozen icicles. | ||||||
int | getGravity() | |||||
Returns the horizontal and vertical alignment of this TextView. | ||||||
CharSequence | getHint() | |||||
Returns the hint that is displayed when the text of the TextView is empty. | ||||||
final | ColorStateList | getHintTextColors() | ||||
Return the color used to paint the hint text. |
||||||
final | KeyListener | getKeyListener() | ||||
final | Layout | getLayout() | ||||
int | getLineBounds(int line, Rect bounds) | |||||
Return the baseline for the specified line (0...getLineCount() - 1) If bounds is not null, return the top, left, right, bottom extents of the specified line in it. | ||||||
int | getLineCount() | |||||
Return the number of lines of text, or 0 if the internal Layout has not been built. | ||||||
int | getLineHeight() | |||||
final | ColorStateList | getLinkTextColors() | ||||
Returns the color used to paint links in the text. |
||||||
final | boolean | getLinksClickable() | ||||
Returns whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(char[], int, int). | ||||||
final | MovementMethod | getMovementMethod() | ||||
TextPaint | getPaint() | |||||
int | getPaintFlags() | |||||
int | getSelectionEnd() | |||||
Convenience for getSelectionEnd(CharSequence). | ||||||
int | getSelectionStart() | |||||
Convenience for getSelectionStart(CharSequence). | ||||||
CharSequence | getText() | |||||
Return the text the TextView is displaying. | ||||||
static | int | getTextColor(Context context, TypedArray attrs, int def) | ||||
Returns the default color from the TextView_textColor attribute from the AttributeSet, if set, or the default color from the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly. | ||||||
final | ColorStateList | getTextColors() | ||||
Return the set of text colors. | ||||||
static | ColorStateList | getTextColors(Context context, TypedArray attrs) | ||||
Returns the TextView_textColor attribute from the Resources.StyledAttributes, if set, or the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly. | ||||||
float | getTextScaleX() | |||||
float | getTextSize() | |||||
int | getTotalPaddingBottom() | |||||
Returns the total bottom padding of the view, including the bottom Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any. | ||||||
int | getTotalPaddingLeft() | |||||
Returns the total left padding of the view, including the left Drawable if any. | ||||||
int | getTotalPaddingRight() | |||||
Returns the total right padding of the view, including the right Drawable if any. | ||||||
int | getTotalPaddingTop() | |||||
Returns the total top padding of the view, including the top Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any. | ||||||
final | TransformationMethod | getTransformationMethod() | ||||
Typeface | getTypeface() | |||||
URLSpan[] | getUrls() | |||||
Returns the list of URLSpans attached to the text (by Linkify or otherwise) if any. | ||||||
boolean | hasSelection() | |||||
Return true iff there is a selection inside this text view. | ||||||
int | length() | |||||
Returns the length, in characters, of the text managed by this TextView | ||||||
boolean | onKeyDown(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is enabled and clickable. | ||||||
boolean | onKeyShortcut(int keyCode, KeyEvent event) | |||||
Called when an unhandled key shortcut event occurs. | ||||||
boolean | onKeyUp(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released. | ||||||
boolean | onPreDraw() | |||||
Callback method to be invoked when the view tree is about to be drawn. | ||||||
void | onRestoreInstanceState(Parcelable state) | |||||
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). | ||||||
Parcelable | onSaveInstanceState() | |||||
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. | ||||||
boolean | onTouchEvent(MotionEvent event) | |||||
Implement this method to handle touch screen motion events. | ||||||
boolean | onTrackballEvent(MotionEvent event) | |||||
Implement this method to handle trackball motion events. | ||||||
void | onWindowFocusChanged(boolean hasWindowFocus) | |||||
Called when the window containing this view gains or loses focus. | ||||||
boolean | performLongClick() | |||||
Call this view's OnLongClickListener, if it is defined. | ||||||
void | removeTextChangedListener(TextWatcher watcher) | |||||
Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes. | ||||||
final | void | setAutoLinkMask(int mask) | ||||
Sets the autolink mask of the text. | ||||||
void | setCompoundDrawablePadding(int pad) | |||||
Sets the size of the padding between the compound drawables and the text. | ||||||
void | setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) | |||||
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. | ||||||
void | setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) | |||||
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. | ||||||
void | setCursorVisible(boolean visible) | |||||
Set whether the cursor is visible. | ||||||
final | void | setEditableFactory(Editable.Factory factory) | ||||
Sets the Factory used to create new Editables. | ||||||
void | setEllipsize(TextUtils.TruncateAt where) | |||||
Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle. | ||||||
void | setEms(int ems) | |||||
Makes the TextView exactly this many ems wide | ||||||
void | setError(CharSequence error) | |||||
Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus. | ||||||
void | setError(CharSequence error, Drawable icon) | |||||
Sets the right-hand compound drawable of the TextView to the specified icon and sets an error message that will be displayed in a popup when the TextView has focus. | ||||||
void | setFilters(InputFilter[] filters) | |||||
Sets the list of input filters that will be used if the buffer is Editable. | ||||||
void | setFreezesText(boolean freezesText) | |||||
Control whether this text view saves its entire text contents when freezing to an icicle, in addition to dynamic state such as cursor position. | ||||||
void | setGravity(int gravity) | |||||
Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself. | ||||||
void | setHeight(int pixels) | |||||
Makes the TextView exactly this many pixels tall. | ||||||
void | setHighlightColor(int color) | |||||
Sets the color used to display the selection highlight. | ||||||
final | void | setHint(CharSequence hint) | ||||
Sets the text to be displayed when the text of the TextView is empty. | ||||||
final | void | setHint(int resid) | ||||
Sets the text to be displayed when the text of the TextView is empty, from a resource. | ||||||
final | void | setHintTextColor(ColorStateList colors) | ||||
Sets the color of the hint text. | ||||||
final | void | setHintTextColor(int color) | ||||
Sets the color of the hint text. | ||||||
void | setHorizontallyScrolling(boolean whether) | |||||
Sets whether the text should be allowed to be wider than the View is. | ||||||
void | setIncludeFontPadding(boolean includepad) | |||||
Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent. | ||||||
void | setKeyListener(KeyListener input) | |||||
Sets the key listener to be used with this TextView. | ||||||
void | setLineSpacing(float add, float mult) | |||||
Sets line spacing for this TextView. | ||||||
void | setLines(int lines) | |||||
Makes the TextView exactly this many lines tall | ||||||
final | void | setLinkTextColor(ColorStateList colors) | ||||
Sets the color of links in the text. | ||||||
final | void | setLinkTextColor(int color) | ||||
Sets the color of links in the text. | ||||||
final | void | setLinksClickable(boolean whether) | ||||
Sets whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(char[], int, int). | ||||||
void | setMaxEms(int maxems) | |||||
Makes the TextView at most this many ems wide | ||||||
void | setMaxHeight(int maxHeight) | |||||
Makes the TextView at most this many pixels tall | ||||||
void | setMaxLines(int maxlines) | |||||
Makes the TextView at most this many lines tall | ||||||
void | setMaxWidth(int maxpixels) | |||||
Makes the TextView at most this many pixels wide | ||||||
void | setMinEms(int minems) | |||||
Makes the TextView at least this many ems wide | ||||||
void | setMinHeight(int minHeight) | |||||
Makes the TextView at least this many pixels tall | ||||||
void | setMinLines(int minlines) | |||||
Makes the TextView at least this many lines tall | ||||||
void | setMinWidth(int minpixels) | |||||
Makes the TextView at least this many pixels wide | ||||||
final | void | setMovementMethod(MovementMethod movement) | ||||
Sets the movement method (arrow key handler) to be used for this TextView. | ||||||
void | setPadding(int left, int top, int right, int bottom) | |||||
Sets the padding. | ||||||
void | setPaintFlags(int flags) | |||||
Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags. | ||||||
void | setScroller(Scroller s) | |||||
void | setSelectAllOnFocus(boolean selectAllOnFocus) | |||||
Set the TextView so that when it takes focus, all the text is selected. | ||||||
void | setShadowLayer(float radius, float dx, float dy, int color) | |||||
Gives the text a shadow of the specified radius and color, the specified distance from its normal position. | ||||||
void | setSingleLine() | |||||
Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input. | ||||||
void | setSingleLine(boolean singleLine) | |||||
If true, sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions. | ||||||
final | void | setSpannableFactory(Spannable.Factory factory) | ||||
Sets the Factory used to create new Spannables. | ||||||
final | void | setText(int resid) | ||||
final | void | setText(int resid, TextView.BufferType type) | ||||
final | void | setText(char[] text, int start, int len) | ||||
Sets the TextView to display the specified slice of the specified char array. | ||||||
void | setText(CharSequence text, TextView.BufferType type) | |||||
Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable. | ||||||
final | void | setText(CharSequence text) | ||||
Sets the string value of the TextView. | ||||||
void | setTextAppearance(Context context, int resid) | |||||
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource. | ||||||
void | setTextColor(int color) | |||||
Sets the text color for all the states (normal, selected, focused) to be this color. | ||||||
void | setTextColor(ColorStateList colors) | |||||
Sets the text color. | ||||||
final | void | setTextKeepState(CharSequence text) | ||||
Like setText(CharSequence), except that the cursor position (if any) is retained in the new text. | ||||||
final | void | setTextKeepState(CharSequence text, TextView.BufferType type) | ||||
Like setText(CharSequence, android.widget.TextView.BufferType), except that the cursor position (if any) is retained in the new text. | ||||||
void | setTextScaleX(float size) | |||||
Sets the extent by which text should be stretched horizontally. | ||||||
void | setTextSize(int unit, float size) | |||||
Set the default text size to a given unit and value. | ||||||
void | setTextSize(float size) | |||||
Set the default text size to the given value, interpreted as "scaled pixel" units. | ||||||
final | void | setTransformationMethod(TransformationMethod method) | ||||
Sets the transformation that is applied to the text that this TextView is displaying. | ||||||
void | setTypeface(Typeface tf, int style) | |||||
Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified. | ||||||
void | setTypeface(Typeface tf) | |||||
Sets the typeface and style in which the text should be displayed. | ||||||
void | setWidth(int pixels) | |||||
Makes the TextView exactly this many pixels wide. |
int | computeHorizontalScrollRange() | |||||
Compute the horizontal range that the horizontal scrollbar represents. |
||||||
int | computeVerticalScrollRange() | |||||
Compute the vertical range that the vertical scrollbar represents. |
||||||
void | drawableStateChanged() | |||||
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown. | ||||||
boolean | getDefaultEditable() | |||||
Subclasses override this to specify default editability. | ||||||
MovementMethod | getDefaultMovementMethod() | |||||
Subclasses override this to specify a default movement method. | ||||||
void | onCreateContextMenu(ContextMenu menu) | |||||
Views should implement this if the view itself is going to add items to the context menu. | ||||||
void | onDraw(Canvas canvas) | |||||
Implement this to do your drawing. | ||||||
void | onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) | |||||
Called by the view system when the focus state of this view changes. | ||||||
void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | |||||
Measure the view and its content to determine the measured width and the measured height. |
||||||
void | onTextChanged(CharSequence text, int start, int before, int after) | |||||
This method is called when the text is changed, in case any subclasses would like to know. | ||||||
boolean | setFrame(int l, int t, int r, int b) | |||||
Assign a size and position to this view. |
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
none | 0x00 | Match no patterns (default) |
web | 0x01 | Match Web URLs |
email | 0x02 | Match email addresses |
phone | 0x04 | Match phone numbers |
map | 0x08 | Match map addresses |
all | 0x0f | Match all patterns (equivalent to web|email|phone|map) |
This corresponds to the global attribute resource symbol autoLink.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol autoText.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
normal | 0 | Can return any CharSequence, possibly a Spanned one if the source text was Spanned. |
spannable | 1 | Can only return Spannable. |
editable | 2 | Can only return Spannable and Editable. |
This corresponds to the global attribute resource symbol bufferType.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
none | 0 | Don't automatically capitalize anything. |
sentences | 1 | Capitalize the first word of each sentence. |
words | 2 | Capitalize the first letter of every word. |
characters | 3 | Capitalize every character. |
This corresponds to the global attribute resource symbol capitalize.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol cursorVisible.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol digits.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol drawableBottom.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol drawableLeft.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol drawablePadding.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol drawableRight.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol drawableTop.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol editable.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
none | 0 | |
start | 1 | |
middle | 2 | |
end | 3 |
This corresponds to the global attribute resource symbol ellipsize.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol ems.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol freezesText.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
top | 0x30 | Push object to the top of its container, not changing its size. |
bottom | 0x50 | Push object to the bottom of its container, not changing its size. |
left | 0x03 | Push object to the left of its container, not changing its size. |
right | 0x05 | Push object to the right of its container, not changing its size. |
center_vertical | 0x10 | Place object in the vertical center of its container, not changing its size. |
fill_vertical | 0x70 | Grow the vertical size of the object if needed so it completely fills its container. |
center_horizontal | 0x01 | Place object in the horizontal center of its container, not changing its size. |
fill_horizontal | 0x07 | Grow the horizontal size of the object if needed so it completely fills its container. |
center | 0x11 | Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |
fill | 0x77 | Grow the horizontal and vertical size of the object if needed so it completely fills its container. |
This corresponds to the global attribute resource symbol gravity.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol height.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol hint.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol includeFontPadding.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol inputMethod.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol lines.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol linksClickable.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol maxEms.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol maxHeight.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol maxLength.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol maxLines.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol maxWidth.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol minEms.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol minHeight.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol minLines.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol minWidth.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
integer | 0x01 | Input is numeric. |
signed | 0x003 | Input is numeric, with sign allowed. |
decimal | 0x05 | Input is numeric, with decimals allowed. |
This corresponds to the global attribute resource symbol numeric.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol password.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol phoneNumber.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol scrollHorizontally.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol selectAllOnFocus.
Must be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol shadowColor.
Must be a floating point value, such as "1.2
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol shadowDx.
Must be a floating point value, such as "1.2
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol shadowDy.
Must be a floating point value, such as "1.2
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol shadowRadius.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol singleLine.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol text.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol textColor.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol textColorHighlight.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol textColorHint.
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol textColorLink.
Must be a floating point value, such as "1.2
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol textScaleX.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol textSize.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
normal | 0 | |
bold | 1 | |
italic | 2 |
This corresponds to the global attribute resource symbol textStyle.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
normal | 0 | |
sans | 1 | |
serif | 2 | |
monospace | 3 |
This corresponds to the global attribute resource symbol typeface.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol width.
depth
.
depth | the indentation level |
---|
Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.
Return the current color selected to paint the hint text.
Return the current color selected for normal text.
null
if no error was set
or if it the error was cleared by the widget after user input.
r | The rectangle to fill in, in this view's coordinates. |
---|
Return the color used to paint the hint text.
line | which line to examine (0..getLineCount() - 1) |
---|---|
bounds | Optional. If not null, it returns the extent of the line |
Returns the color used to paint links in the text.
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
state | The frozen state that had previously been returned by onSaveInstanceState(). |
---|
Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
event | The motion event. |
---|
event | The motion event. |
---|
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
null
to turn off ellipsizing.
error
is null
, the error message and icon
will be cleared.
error
is null
, the error message will
be cleared (and you should provide a null
icon as well).
freezesText | Controls whether a frozen icicle should include the entire text data: true to include it, false to not. |
---|
Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call setFocusable(boolean) again after calling this to get the focusability back the way you want it.
mult
and have add
added to it.
Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call setFocusable(boolean) again after calling this to get the focusability back the way you want it.
left | the left padding in pixels |
---|---|
top | the top padding in pixels |
right | the right padding in pixels |
bottom | the bottom padding in pixels |
text | The new text to place in the text view. |
---|
unit | The desired dimension unit. |
---|---|
size | The desired size in the given units. |
size | The scaled pixel size. |
---|
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollExtent() and computeHorizontalScrollOffset().
The default range is the drawing width of this view.
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollExtent() and computeVerticalScrollOffset().
The default range is the drawing height of this view.
Be sure to call through to the superclass when overriding this function.
menu | the context menu to populate |
---|
canvas | the canvas on which the background will be drawn |
---|
focused | True if the View has focus; false otherwise. |
---|---|
direction | The direction focus has moved when requestFocus() is called to give this view focus. Values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. It may not always apply, in which case use the default. |
previouslyFocusedRect | The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null otherwise.
|
Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
CONTRACT: When overriding this method, you
must call setMeasuredDimension(int, int) to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
measure(int, int). Calling the superclass'
onMeasure(int, int) is a valid use.
The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.
If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).
widthMeasureSpec | horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
---|---|
heightMeasureSpec | vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
text | The text the TextView is displaying. |
---|---|
start | The offset of the start of the range of the text that was modified. |
before | The offset of the former end of the range of the
text that was modified. If text was simply inserted,
this will be the same as start .
If text was replaced with new text or deleted, the
length of the old text was before-start . |
after | The offset of the end of the range of the text
that was modified. If text was simply deleted,
this will be the same as start .
If text was replaced with new text or inserted,
the length of the new text is after-start .
|
l | Left position, relative to parent |
---|---|
t | Top position, relative to parent |
r | Right position, relative to parent |
b | Bottom position, relative to parent |
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |