TextView
open class TextView : View, ViewTreeObserver.OnPreDrawListener
Known Direct Subclasses
| Button |
A user interface element the user can tap or click to perform an action.
|
| CheckedTextView |
An extension to TextView that supports the Checkable interface and displays.
|
| Chronometer |
Class that implements a simple timer.
|
| DigitalClock |
Like AnalogClock, but digital.
|
| EditText |
A user interface element for entering and modifying text.
|
| TextClock |
TextClock can display the current date and/or time as a formatted string.
|
|
Known Indirect Subclasses
| AutoCompleteTextView |
An editable text view that shows completion suggestions automatically while the user is typing.
|
| CheckBox |
A checkbox is a specific type of two-states button that can be either checked or unchecked.
|
| CompoundButton |
A button with two states, checked and unchecked.
|
| ExtractEditText |
* Specialization of EditText for showing and interacting with the extracted text in a full-screen input method.
|
| MultiAutoCompleteTextView |
An editable text view, extending AutoCompleteTextView, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing.
|
| RadioButton |
A radio button is a two-states button that can be either checked or unchecked.
|
| Switch |
A Switch is a two-state toggle switch widget that can select between two options.
|
| ToggleButton |
Displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".
|
|
A user interface element that displays text to the user. To provide user-editable text, see EditText.
The following code sample shows a typical use, with an XML layout and code to modify the contents of the text view:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text_view_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/hello" />
</LinearLayout>
This code sample demonstrates how to modify the contents of the text view defined in the previous XML layout:
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView helloTextView = (TextView) findViewById(R.id.text_view_id);
helloTextView.setText(R.string.user_greeting);
}
}
To customize the appearance of TextView, see Styles and Themes.
XML attributes
See TextView Attributes, View Attributes
Summary
Nested classes
|
|
Type of the text buffer that defines the characteristics of the text such as static, styleable, or editable.
|
| abstract |
Interface definition for a callback to be invoked when an action is performed on the editor.
|
| open |
User interface state that is stored by TextView for implementing View#onSaveInstanceState.
|
XML attributes
|
android:allowUndo |
Whether undo should be allowed for editable text. |
android:autoLink |
Controls whether links such as urls and email addresses are automatically found and converted to clickable links. |
android:autoSizeMaxTextSize |
The maximum text size constraint to be used when auto-sizing text. |
android:autoSizeMinTextSize |
The minimum text size constraint to be used when auto-sizing text. |
android:autoSizePresetSizes |
Resource array of dimensions to be used in conjunction with autoSizeTextType set to uniform . |
android:autoSizeStepGranularity |
Specify the auto-size step size if autoSizeTextType is set to uniform . |
android:autoSizeTextType |
Specify the type of auto-size. |
android:autoText |
If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. |
android:breakStrategy |
Break strategy (control over paragraph layout). |
android:bufferType |
Determines the minimum type that getText() will return. |
android:capitalize |
If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. |
android:cursorVisible |
Makes the cursor visible (the default) or invisible. |
android:digits |
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 |
The drawable to be drawn below the text. |
android:drawableEnd |
The drawable to be drawn to the end of the text. |
android:drawableLeft |
The drawable to be drawn to the left of the text. |
android:drawablePadding |
The padding between the drawables and the text. |
android:drawableRight |
The drawable to be drawn to the right of the text. |
android:drawableStart |
The drawable to be drawn to the start of the text. |
android:drawableTint |
Tint to apply to the compound (left, top, etc.) drawables. |
android:drawableTintMode |
Blending mode used to apply the compound (left, top, etc.) drawables tint. |
android:drawableTop |
The drawable to be drawn above the text. |
android:editable |
If set, specifies that this TextView has an input method. |
android:editorExtras |
Reference to an <input-extras> XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. |
android:elegantTextHeight |
Elegant text height, especially for less compacted complex script text. |
android:ellipsize |
If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. |
android:ems |
Makes the TextView be exactly this many ems wide. |
android:enabled |
Specifies whether the widget is enabled. |
android:fallbackLineSpacing |
Whether to respect the ascent and descent of the fallback fonts that are used in displaying the text. |
android:fontFamily |
Font family (named by string or as a font resource reference) for the text. |
android:fontFeatureSettings |
Font feature settings. |
android:fontVariationSettings |
Font variation settings. |
android:freezesText |
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 |
Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. |
android:height |
Makes the TextView be exactly this tall. |
android:hint |
Hint text to display when the text is empty. |
android:hyphenationFrequency |
Frequency of automatic hyphenation. |
android:imeActionId |
Supply a value for EditorInfo. |
android:imeActionLabel |
Supply a value for EditorInfo. |
android:imeOptions |
Additional features you can enable in an IME associated with an editor to improve the integration with your application. |
android:includeFontPadding |
Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. |
android:inputMethod |
If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). |
android:inputType |
The type of data being placed in a text field, used to help an input method decide how to let the user enter text. |
android:justificationMode |
Mode for justification. |
android:letterSpacing |
Text letter-spacing. |
android:lineSpacingExtra |
Extra spacing between lines of text. |
android:lineSpacingMultiplier |
Extra spacing between lines of text, as a multiplier. |
android:lines |
Makes the TextView be exactly this many lines tall. |
android:linksClickable |
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:marqueeRepeatLimit |
The number of times to repeat the marquee animation. |
android:maxEms |
Makes the TextView be at most this many ems wide. |
android:maxHeight |
Makes the TextView be at most this many pixels tall. |
android:maxLength |
Set an input filter to constrain the text length to the specified number. |
android:maxLines |
Makes the TextView be at most this many lines tall. |
android:maxWidth |
Makes the TextView be at most this many pixels wide. |
android:minEms |
Makes the TextView be at least this many ems wide. |
android:minHeight |
Makes the TextView be at least this many pixels tall. |
android:minLines |
Makes the TextView be at least this many lines tall. |
android:minWidth |
Makes the TextView be at least this many pixels wide. |
android:numeric |
If set, specifies that this TextView has a numeric input method. |
android:password |
Whether the characters of the field are displayed as password dots instead of themselves. |
android:phoneNumber |
If set, specifies that this TextView has a phone number input method. |
android:privateImeOptions |
An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. |
android:scrollHorizontally |
Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). |
android:selectAllOnFocus |
If the text is selectable, select it all when the view takes focus. |
android:shadowColor |
Place a blurred shadow of text underneath the text, drawn with the specified color. |
android:shadowDx |
Horizontal offset of the text shadow. |
android:shadowDy |
Vertical offset of the text shadow. |
android:shadowRadius |
Blur radius of the text shadow. |
android:singleLine |
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 |
Text to display. |
android:textAppearance |
Base text color, typeface, size, and style. |
android:textColor |
Text color. |
android:textColorHighlight |
Color of the text selection highlight. |
android:textColorHint |
Color of the hint text. |
android:textColorLink |
Text color for links. |
android:textCursorDrawable |
Reference to a drawable that will be drawn under the insertion cursor. |
android:textFontWeight |
Weight for the font used in the TextView. |
android:textScaleX |
Sets the horizontal scaling factor for the text. |
android:textSelectHandle |
Reference to a drawable that will be used to display a text selection anchor for positioning the cursor within text. |
android:textSelectHandleLeft |
Reference to a drawable that will be used to display a text selection anchor on the left side of a selection region. |
android:textSelectHandleRight |
Reference to a drawable that will be used to display a text selection anchor on the right side of a selection region. |
android:textSize |
Size of the text. |
android:textStyle |
Style (normal, bold, italic, bold|italic) for the text. |
android:typeface |
Typeface (normal, sans, serif, monospace) for the text. |
android:width |
Makes the TextView be exactly this wide. |
Inherited XML attributes
|
From class View
android:accessibilityHeading |
Whether or not this view is a heading for accessibility purposes.
May be a boolean value, such as "true" or "false".
|
android:alpha |
alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque).
May be a floating point value, such as "1.2".
|
android:background |
A drawable to use as the background. This can be either a reference to a full drawable resource (such as a PNG image, 9-patch, XML state list description, etc), or a solid color such as "#ff000000" (black).
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
|
android:clickable |
Defines whether this view reacts to click events.
May be a boolean value, such as "true" or "false".
|
android:contentDescription |
Defines text that briefly describes content of the view. This property is used primarily for accessibility. Since some views do not have textual representation this attribute can be used for providing such.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
|
android:drawingCacheQuality |
Defines the quality of translucent drawing caches. This property is used only when the drawing cache is enabled and translucent. The default value is auto. Deprecated: The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11.
Must be one of the following constant values.
| Constant |
Value |
Description |
| auto |
0 |
Lets the framework decide what quality level should be used for the drawing cache. Deprecated: The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11. |
| high |
2 |
High quality. When set to high quality, the drawing cache uses a higher color depth but uses more memory. Deprecated: The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11. |
| low |
1 |
Low quality. When set to low quality, the drawing cache uses a lower color depth, thus losing precision in rendering gradients, but uses less memory. Deprecated: The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11. |
|
android:duplicateParentState |
When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself.
May be a boolean value, such as "true" or "false".
|
android:fadeScrollbars |
Defines whether to fade out scrollbars when they are not in use.
May be a boolean value, such as "true" or "false".
|
android:fadingEdgeLength |
Defines the length of the fading edges.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:filterTouchesWhenObscured |
Specifies whether to filter touches when the view's window is obscured by another visible window. When set to true, the view will not receive touches whenever a toast, dialog or other window appears above the view's window. Refer to the android.view.View security documentation for more details.
May be a boolean value, such as "true" or "false".
|
android:fitsSystemWindows |
Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.
May be a boolean value, such as "true" or "false".
|
android:focusable |
Controls whether a view can take focus. By default, this is "auto" which lets the framework determine whether a user can move focus to a view. By setting this attribute to true the view is allowed to take focus. By setting it to "false" the view will not take focus. This value does not impact the behavior of directly calling android.view.View#requestFocus, which will always request focus regardless of this view. It only impacts where focus navigation will try to move focus.
May be a boolean value, such as "true" or "false".
Must be one of the following constant values.
| Constant |
Value |
Description |
| auto |
10 |
|
|
android:focusableInTouchMode |
Boolean that controls whether a view can take focus while in touch mode. If this is true for a view, that view can gain focus when clicked on, and can keep focus if another view is clicked on that doesn't have this attribute set to true.
May be a boolean value, such as "true" or "false".
|
android:focusedByDefault |
Whether this view is a default-focus view. Only one view per keyboard navigation cluster can have this attribute set to true. See android.view.View#setFocusedByDefault(boolean).
May be a boolean value, such as "true" or "false".
|
android:hapticFeedbackEnabled |
Boolean that controls whether a view should have haptic feedback enabled for events such as long presses.
May be a boolean value, such as "true" or "false".
|
android:id |
Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById(). This must be a resource reference; typically you set this using the @+ syntax to create a new ID resources. For example: android:id="@+id/my_id" which allows you to later retrieve the view with findViewById(R.id.my_id).
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:isScrollContainer |
Set this if the view will serve as a scrolling container, meaning that it can be resized to shrink its overall window so that there will be space for an input method. If not set, the default value will be true if "scrollbars" has the vertical scrollbar set, else it will be false.
May be a boolean value, such as "true" or "false".
|
android:keepScreenOn |
Controls whether the view's window should keep the screen on while visible.
May be a boolean value, such as "true" or "false".
|
android:keyboardNavigationCluster |
Whether this view is a root of a keyboard navigation cluster. See android.view.View#setKeyboardNavigationCluster(boolean).
May be a boolean value, such as "true" or "false".
|
android:layerType |
Specifies the type of layer backing this view. The default value is none. Refer to android.view.View#setLayerType(int, android.graphics.Paint) for more information.
Must be one of the following constant values.
|
android:layoutDirection |
Defines the direction of layout drawing. This typically is associated with writing direction of the language script used. The possible values are "ltr" for Left-to-Right, "rtl" for Right-to-Left, "locale", and "inherit" from parent view. If there is nothing to inherit, "locale" is used. "locale" falls back to "en-US". "ltr" is the direction used in "en-US". The default for this attribute is "inherit".
Must be one of the following constant values.
| Constant |
Value |
Description |
| inherit |
2 |
Inherit from parent. |
| locale |
3 |
Locale. |
| ltr |
0 |
Left-to-Right. |
| rtl |
1 |
Right-to-Left. |
|
android:longClickable |
Defines whether this view reacts to long click events.
May be a boolean value, such as "true" or "false".
|
android:minHeight |
Defines the minimum height of the view. It is not guaranteed the view will be able to achieve this minimum height (for example, if its parent layout constrains it with less available height).
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:minWidth |
Defines the minimum width of the view. It is not guaranteed the view will be able to achieve this minimum width (for example, if its parent layout constrains it with less available width).
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:nextClusterForward |
Defines the next keyboard navigation cluster. If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:nextFocusDown |
Defines the next view to give focus to when the next focus is android.view.View#FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:nextFocusLeft |
Defines the next view to give focus to when the next focus is android.view.View#FOCUS_LEFT. If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:nextFocusRight |
Defines the next view to give focus to when the next focus is android.view.View#FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:nextFocusUp |
Defines the next view to give focus to when the next focus is android.view.View#FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:onClick |
Name of the method in this View's context to invoke when the view is clicked. This name must correspond to a public method that takes exactly one parameter of type View. For instance, if you specify android:onClick="sayHello", you must declare a public void sayHello(View v) method of your context (typically, your Activity).
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
|
android:outlineAmbientShadowColor |
Sets the color of the ambient shadow that is drawn when the view has a positive Z or elevation value.
By default the shadow color is black. Generally, this color will be opaque so the intensity of the shadow is consistent between different views with different colors.
The opacity of the final ambient shadow is a function of the shadow caster height, the alpha channel of the outlineAmbientShadowColor (typically opaque), and the android.R.attr#ambientShadowAlpha theme attribute.
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
|
android:outlineSpotShadowColor |
Sets the color of the spot shadow that is drawn when the view has a positive Z or elevation value.
By default the shadow color is black. Generally, this color will be opaque so the intensity of the shadow is consistent between different views with different colors.
The opacity of the final spot shadow is a function of the shadow caster height, the alpha channel of the outlineSpotShadowColor (typically opaque), and the android.R.attr#spotShadowAlpha theme attribute.
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
|
android:padding |
Sets the padding, in pixels, of all four edges. Padding is defined as space between the edges of the view and the view's content. This value will take precedence over any of the edge-specific values (paddingLeft, paddingTop, paddingRight, paddingBottom, paddingHorizontal and paddingVertical), but will not override paddingStart or paddingEnd, if set. A view's size will include its padding. If a android.R.attr#background is provided, the padding will initially be set to that (0 if the drawable does not have padding). Explicitly setting a padding value will override the corresponding padding found in the background.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingBottom |
Sets the padding, in pixels, of the bottom edge; see android.R.attr#padding.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingEnd |
Sets the padding, in pixels, of the end edge; see android.R.attr#padding.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingHorizontal |
Sets the padding, in pixels, of the left and right edges; see android.R.attr#padding. This value will take precedence over paddingLeft and paddingRight, but not paddingStart or paddingEnd (if set).
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingLeft |
Sets the padding, in pixels, of the left edge; see android.R.attr#padding.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingRight |
Sets the padding, in pixels, of the right edge; see android.R.attr#padding.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingStart |
Sets the padding, in pixels, of the start edge; see android.R.attr#padding.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingTop |
Sets the padding, in pixels, of the top edge; see android.R.attr#padding.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:paddingVertical |
Sets the padding, in pixels, of the top and bottom edges; see android.R.attr#padding. This value will take precedence over paddingTop and paddingBottom, if set.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:requiresFadingEdge |
Defines which edges should be faded on scrolling.
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| horizontal |
1000 |
Fades horizontal edges only. |
| none |
0 |
No edge is faded. |
| vertical |
2000 |
Fades vertical edges only. |
|
android:rotation |
rotation of the view, in degrees.
May be a floating point value, such as "1.2".
|
android:rotationX |
rotation of the view around the x axis, in degrees.
May be a floating point value, such as "1.2".
|
android:rotationY |
rotation of the view around the y axis, in degrees.
May be a floating point value, such as "1.2".
|
android:saveEnabled |
If false, no state will be saved for this view when it is being frozen. The default is true, allowing the view to be saved (however it also must have an ID assigned to it for its state to be saved). Setting this to false only disables the state for this view, not for its children which may still be saved.
May be a boolean value, such as "true" or "false".
|
android:scaleX |
scale of the view in the x direction.
May be a floating point value, such as "1.2".
|
android:scaleY |
scale of the view in the y direction.
May be a floating point value, such as "1.2".
|
android:scrollX |
The initial horizontal scroll offset, in pixels.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:scrollY |
The initial vertical scroll offset, in pixels.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:scrollbarAlwaysDrawHorizontalTrack |
Defines whether the horizontal scrollbar track should always be drawn.
May be a boolean value, such as "true" or "false".
|
android:scrollbarAlwaysDrawVerticalTrack |
Defines whether the vertical scrollbar track should always be drawn.
May be a boolean value, such as "true" or "false".
|
android:scrollbarDefaultDelayBeforeFade |
Defines the delay in milliseconds that a scrollbar waits before fade out.
May be an integer value, such as "100".
|
android:scrollbarFadeDuration |
Defines the delay in milliseconds that a scrollbar takes to fade out.
May be an integer value, such as "100".
|
android:scrollbarSize |
Sets the width of vertical scrollbars and height of horizontal scrollbars.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:scrollbarStyle |
Controls the scrollbar style and position. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use insideOverlay or insideInset. If you want them to appear at the edge of the view, ignoring the padding, then you can use outsideOverlay or outsideInset.
Must be one of the following constant values.
| Constant |
Value |
Description |
| insideInset |
1000000 |
Inside the padding and inset. |
| insideOverlay |
0 |
Inside the padding and overlaid. |
| outsideInset |
3000000 |
Edge of the view and inset. |
| outsideOverlay |
2000000 |
Edge of the view and overlaid. |
|
android:scrollbarThumbHorizontal |
Defines the horizontal scrollbar thumb drawable.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:scrollbarThumbVertical |
Defines the vertical scrollbar thumb drawable.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:scrollbarTrackHorizontal |
Defines the horizontal scrollbar track drawable.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:scrollbarTrackVertical |
Defines the vertical scrollbar track drawable.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:scrollbars |
Defines which scrollbars should be displayed on scrolling or not.
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| horizontal |
100 |
Displays horizontal scrollbar only. |
| none |
0 |
No scrollbar is displayed. |
| vertical |
200 |
Displays vertical scrollbar only. |
|
android:soundEffectsEnabled |
Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching.
May be a boolean value, such as "true" or "false".
|
android:stateListAnimator |
Sets the state-based animator for the View.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:tag |
Supply a tag for this view containing a String, to be retrieved later with View.getTag() or searched for with View.findViewWithTag(). It is generally preferable to use IDs (through the android:id attribute) instead of tags because they are faster and allow for compile-time type checking.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
|
android:textAlignment |
Defines the alignment of the text.
May be an integer value, such as "100".
Must be one of the following constant values.
| Constant |
Value |
Description |
| center |
4 |
Center the paragraph, for example: ALIGN_CENTER. |
| gravity |
1 |
Default for the root view. The gravity determines the alignment, ALIGN_NORMAL, ALIGN_CENTER, or ALIGN_OPPOSITE, which are relative to each paragraph’s text direction. |
| inherit |
0 |
Default. |
| textEnd |
3 |
Align to the end of the paragraph, for example: ALIGN_OPPOSITE. |
| textStart |
2 |
Align to the start of the paragraph, for example: ALIGN_NORMAL. |
| viewEnd |
6 |
Align to the end of the view, which is ALIGN_RIGHT if the view’s resolved layoutDirection is LTR, and ALIGN_LEFT otherwise. |
| viewStart |
5 |
Align to the start of the view, which is ALIGN_LEFT if the view’s resolved layoutDirection is LTR, and ALIGN_RIGHT otherwise. |
|
android:textDirection |
Defines the direction of the text.
May be an integer value, such as "100".
Must be one of the following constant values.
| Constant |
Value |
Description |
| anyRtl |
2 |
The paragraph direction is RTL if it contains any strong RTL character, otherwise it is LTR if it contains any strong LTR characters. If there are neither, the paragraph direction is the view’s resolved layout direction. |
| firstStrong |
1 |
Default for the root view. The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is the view’s resolved layout direction. |
| firstStrongLtr |
6 |
The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is LTR. |
| firstStrongRtl |
7 |
The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is RTL. |
| inherit |
0 |
Default. |
| locale |
5 |
The paragraph direction is coming from the system Locale. |
| ltr |
3 |
The paragraph direction is left to right. |
| rtl |
4 |
The paragraph direction is right to left. |
|
android:theme |
Specifies a theme override for a view. When a theme override is set, the view will be inflated using a android.content.Context themed with the specified resource. During XML inflation, any child views under the view with a theme override will inherit the themed context.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
|
android:transformPivotX |
x location of the pivot point around which the view will rotate and scale. This xml attribute sets the pivotX property of the View.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:transformPivotY |
y location of the pivot point around which the view will rotate and scale. This xml attribute sets the pivotY property of the View.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:transitionName |
Names a View such that it can be identified for Transitions. Names should be unique in the View hierarchy.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
|
android:translationX |
translation in x of the view. This value is added post-layout to the left property of the view, which is set by its layout.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:translationY |
translation in y of the view. This value is added post-layout to the top property of the view, which is set by its layout.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:translationZ |
translation in z of the view. This value is added to its elevation.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
|
android:visibility |
Controls the initial visibility of the view.
Must be one of the following constant values.
| Constant |
Value |
Description |
| gone |
2 |
Completely hidden, as if the view had not been added. |
| invisible |
1 |
Not displayed, but taken into account during layout (space is left for it). |
| visible |
0 |
Visible on screen; the default value. |
|
|
Constants
|
| static Int |
The TextView does not auto-size text (default).
|
| static Int |
The TextView scales text size both horizontally and vertically to fit within the container.
|
Inherited constants
|
From class View
Int |
ACCESSIBILITY_LIVE_REGION_ASSERTIVE
Live region mode specifying that accessibility services should interrupt ongoing speech to immediately announce changes to this view.
Use with setAccessibilityLiveRegion(int).
|
Int |
ACCESSIBILITY_LIVE_REGION_NONE
Live region mode specifying that accessibility services should not automatically announce changes to this view. This is the default live region mode for most views.
Use with setAccessibilityLiveRegion(int).
|
Int |
ACCESSIBILITY_LIVE_REGION_POLITE
Live region mode specifying that accessibility services should announce changes to this view.
Use with setAccessibilityLiveRegion(int).
|
Int |
AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
Flag requesting you to add views that are marked as not important for autofill (see setImportantForAutofill(int)) to a ViewStructure.
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE
Hint indicating that this view can be autofilled with a credit card expiration date.
It should be used when the credit card expiration date is represented by just one view; if it is represented by more than one (for example, one view for the month and another view for the year), then each of these views should use the hint specific for the unit (AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, or AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR).
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE}).
When annotating a view with this hint, it's recommended to use a date autofill value to avoid ambiguity when the autofill service provides a value for it. To understand why a value can be ambiguous, consider "April of 2020", which could be represented as either of the following options:
"04/2020"
"4/2020"
"2020/04"
"2020/4"
"April/2020"
"Apr/2020"
You define a date autofill value for the view by overriding the following methods:
getAutofillType() to return AUTOFILL_TYPE_DATE.
getAutofillValue() to return a AutofillValue#forDate(long).
autofill(android.view.autofill.AutofillValue) to expect a data autofillvalue.
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY
Hint indicating that this view can be autofilled with a credit card expiration day.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH
Hint indicating that this view can be autofilled with a credit card expiration month.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH}).
When annotating a view with this hint, it's recommended to use a text autofill value whose value is the numerical representation of the month, starting on 1 to avoid ambiguity when the autofill service provides a value for it. To understand why a value can be ambiguous, consider "January", which could be represented as either of
"1": recommended way.
"0": if following the Calendar#MONTH convention.
"January": full name, in English.
"jan": abbreviated name, in English.
"Janeiro": full name, in another language.
Another recommended approach is to use a date autofill value - see AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE for more details.
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
Hint indicating that this view can be autofilled with a credit card expiration year.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_CREDIT_CARD_NUMBER
Hint indicating that this view can be autofilled with a credit card number.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_CREDIT_CARD_NUMBER}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE
Hint indicating that this view can be autofilled with a credit card security code.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_EMAIL_ADDRESS
Hint indicating that this view can be autofilled with an email address.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_EMAIL_ADDRESS}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_NAME
Hint indicating that this view can be autofilled with a user's real name.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_NAME}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_PASSWORD
Hint indicating that this view can be autofilled with a password.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_PASSWORD}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_PHONE
Hint indicating that this view can be autofilled with a phone number.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_PHONE}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_POSTAL_ADDRESS
Hint indicating that this view can be autofilled with a postal address.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_POSTAL_ADDRESS}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_POSTAL_CODE
Hint indicating that this view can be autofilled with a postal code.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_POSTAL_CODE}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
String |
AUTOFILL_HINT_USERNAME
Hint indicating that this view can be autofilled with a username.
Can be used with either setAutofillHints(java.lang.String[]) or android:autofillHint (in which case the value should be {@value #AUTOFILL_HINT_USERNAME}).
See setAutofillHints(java.lang.String...) for more info about autofill hints.
|
Int |
AUTOFILL_TYPE_DATE
Autofill type for a field that contains a date, which is represented by a long representing the number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT (see java.util.Date#getTime().
AutofillValue instances for autofilling a View can be obtained through AutofillValue#forDate(long), and the values passed to autofill a View can be fetched through AutofillValue#getDateValue().
|
Int |
AUTOFILL_TYPE_LIST
Autofill type for a selection list field, which is filled by an int representing the element index inside the list (starting at 0).
AutofillValue instances for autofilling a View can be obtained through AutofillValue#forList(int), and the value passed to autofill a View can be fetched through AutofillValue#getListValue().
The available options in the selection list are typically provided by android.app.assist.AssistStructure.ViewNode#getAutofillOptions().
|
Int |
AUTOFILL_TYPE_NONE
Autofill type for views that cannot be autofilled.
Typically used when the view is read-only; for example, a text label.
|
Int |
AUTOFILL_TYPE_TEXT
Autofill type for a text field, which is filled by a CharSequence.
AutofillValue instances for autofilling a View can be obtained through AutofillValue#forText(CharSequence), and the value passed to autofill a View can be fetched through AutofillValue#getTextValue().
|
Int |
AUTOFILL_TYPE_TOGGLE
Autofill type for a togglable field, which is filled by a boolean.
AutofillValue instances for autofilling a View can be obtained through AutofillValue#forToggle(boolean), and the value passed to autofill a View can be fetched through AutofillValue#getToggleValue().
|
Int |
DRAG_FLAG_GLOBAL
Flag indicating that a drag can cross window boundaries. When startDragAndDrop(android.content.ClipData,android.view.View.DragShadowBuilder,java.lang.Object,int) is called with this flag set, all visible applications with targetSdkVersion >= API 24 will be able to participate in the drag operation and receive the dragged content.
If this is the only flag set, then the drag recipient will only have access to text data and intents contained in the ClipData object. Access to URIs contained in the ClipData is determined by other DRAG_FLAG_GLOBAL_* flags
|
Int |
DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION
When this flag is used with DRAG_FLAG_GLOBAL_URI_READ and/or , the URI permission grant can be persisted across device reboots until explicitly revoked with android.content.Context#revokeUriPermission(Uri, int) Context.revokeUriPermission}.
|
Int |
DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION
When this flag is used with DRAG_FLAG_GLOBAL_URI_READ and/or , the URI permission grant applies to any URI that is a prefix match against the original granted URI.
|
Int |
DRAG_FLAG_GLOBAL_URI_READ
When this flag is used with DRAG_FLAG_GLOBAL, the drag recipient will be able to request read access to the content URI(s) contained in the ClipData object.
|
Int |
DRAG_FLAG_GLOBAL_URI_WRITE
When this flag is used with DRAG_FLAG_GLOBAL, the drag recipient will be able to request write access to the content URI(s) contained in the ClipData object.
|
Int |
DRAG_FLAG_OPAQUE
Flag indicating that the drag shadow will be opaque. When startDragAndDrop(android.content.ClipData,android.view.View.DragShadowBuilder,java.lang.Object,int) is called with this flag set, the drag shadow will be opaque, otherwise, it will be semitransparent.
|
Int |
DRAWING_CACHE_QUALITY_AUTO
Enables automatic quality mode for the drawing cache.
|
Int |
DRAWING_CACHE_QUALITY_HIGH
Enables high quality mode for the drawing cache.
|
Int |
DRAWING_CACHE_QUALITY_LOW
Enables low quality mode for the drawing cache.
|
Int |
FIND_VIEWS_WITH_CONTENT_DESCRIPTION
Find find views that contain the specified content description.
|
Int |
FIND_VIEWS_WITH_TEXT
Find views that render the specified text.
|
Int |
FOCUSABLE
This view wants keystrokes.
Use with setFocusable(int) and android:focusable.
|
Int |
FOCUSABLES_ALL
View flag indicating whether addFocusables(java.util.ArrayList,int,int) should add all focusable Views regardless if they are focusable in touch mode.
|
Int |
FOCUSABLES_TOUCH_MODE
View flag indicating whether addFocusables(java.util.ArrayList,int,int) should add only Views focusable in touch mode.
|
Int |
FOCUSABLE_AUTO
This view determines focusability automatically. This is the default.
Use with setFocusable(int) and android:focusable.
|
Int |
FOCUS_BACKWARD
Use with focusSearch(int). Move focus to the previous selectable item.
|
Int |
FOCUS_DOWN
Use with focusSearch(int). Move focus down.
|
Int |
FOCUS_FORWARD
Use with focusSearch(int). Move focus to the next selectable item.
|
Int |
FOCUS_LEFT
Use with focusSearch(int). Move focus to the left.
|
Int |
FOCUS_RIGHT
Use with focusSearch(int). Move focus to the right.
|
Int |
FOCUS_UP
Use with focusSearch(int). Move focus up.
|
Int |
GONE
This view is invisible, and it doesn't take any space for layout purposes. Use with setVisibility and android:visibility.
|
Int |
HAPTIC_FEEDBACK_ENABLED
View flag indicating whether this view should have haptic feedback enabled for events such as long presses.
|
Int |
IMPORTANT_FOR_ACCESSIBILITY_AUTO
Automatically determine whether a view is important for accessibility.
|
Int |
IMPORTANT_FOR_ACCESSIBILITY_NO
The view is not important for accessibility.
|
Int |
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
The view is not important for accessibility, nor are any of its descendant views.
|
Int |
IMPORTANT_FOR_ACCESSIBILITY_YES
The view is important for accessibility.
|
Int |
IMPORTANT_FOR_AUTOFILL_AUTO
Automatically determine whether a view is important for autofill.
|
Int |
IMPORTANT_FOR_AUTOFILL_NO
The view is not important for autofill, but its children (if any) will be traversed.
|
Int |
IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS
The view is not important for autofill, and its children (if any) will not be traversed.
|
Int |
IMPORTANT_FOR_AUTOFILL_YES
The view is important for autofill, and its children (if any) will be traversed.
|
Int |
IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS
The view is important for autofill, but its children (if any) will not be traversed.
|
Int |
INVISIBLE
This view is invisible, but it still takes up space for layout purposes. Use with setVisibility and android:visibility.
|
Int |
KEEP_SCREEN_ON
View flag indicating that the screen should remain on while the window containing this view is visible to the user. This effectively takes care of automatically setting the WindowManager's WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON.
|
Int |
LAYER_TYPE_HARDWARE
Indicates that the view has a hardware layer. A hardware layer is backed by a hardware specific texture (generally Frame Buffer Objects or FBO on OpenGL hardware) and causes the view to be rendered using Android's hardware rendering pipeline, but only if hardware acceleration is turned on for the view hierarchy. When hardware acceleration is turned off, hardware layers behave exactly as software layers.
A hardware layer is useful to apply a specific color filter and/or blending mode and/or translucency to a view and all its children.
A hardware layer can be used to cache a complex view tree into a texture and reduce the complexity of drawing operations. For instance, when animating a complex view tree with a translation, a hardware layer can be used to render the view tree only once.
A hardware layer can also be used to increase the rendering quality when rotation transformations are applied on a view. It can also be used to prevent potential clipping issues when applying 3D transforms on a view.
|
Int |
LAYER_TYPE_NONE
Indicates that the view does not have a layer.
|
Int |
LAYER_TYPE_SOFTWARE
Indicates that the view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled.
Software layers have various usages:
When the application is not using hardware acceleration, a software layer is useful to apply a specific color filter and/or blending mode and/or translucency to a view and all its children.
When the application is using hardware acceleration, a software layer is useful to render drawing primitives not supported by the hardware accelerated pipeline. It can also be used to cache a complex view tree into a texture and reduce the complexity of drawing operations. For instance, when animating a complex view tree with a translation, a software layer can be used to render the view tree only once.
Software layers should be avoided when the affected view tree updates often. Every update will require to re-render the software layer, which can potentially be slow (particularly when hardware acceleration is turned on since the layer will have to be uploaded into a hardware texture after every update.)
|
Int |
LAYOUT_DIRECTION_INHERIT
Horizontal layout direction of this view is inherited from its parent. Use with setLayoutDirection.
|
Int |
LAYOUT_DIRECTION_LOCALE
Horizontal layout direction of this view is from deduced from the default language script for the locale. Use with setLayoutDirection.
|
Int |
LAYOUT_DIRECTION_LTR
Horizontal layout direction of this view is from Left to Right. Use with setLayoutDirection.
|
Int |
LAYOUT_DIRECTION_RTL
Horizontal layout direction of this view is from Right to Left. Use with setLayoutDirection.
|
Int |
MEASURED_HEIGHT_STATE_SHIFT
Bit shift of MEASURED_STATE_MASK to get to the height bits for functions that combine both width and height into a single int, such as getMeasuredState() and the childState argument of resolveSizeAndState(int,int,int).
|
Int |
MEASURED_SIZE_MASK
Bits of getMeasuredWidthAndState() and getMeasuredWidthAndState() that provide the actual measured size.
|
Int |
MEASURED_STATE_MASK
Bits of getMeasuredWidthAndState() and getMeasuredWidthAndState() that provide the additional state bits.
|
Int |
MEASURED_STATE_TOO_SMALL
Bit of getMeasuredWidthAndState() and getMeasuredWidthAndState() that indicates the measured size is smaller that the space the view would like to have.
|
Int |
NOT_FOCUSABLE
This view does not want keystrokes.
Use with setFocusable(int) and android:focusable.
|
Int |
NO_ID
Used to mark a View that has no ID.
|
Int |
OVER_SCROLL_ALWAYS
Always allow a user to over-scroll this view, provided it is a view that can scroll.
|
Int |
OVER_SCROLL_IF_CONTENT_SCROLLS
Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.
|
Int |
OVER_SCROLL_NEVER
Never allow a user to over-scroll this view.
|
Int |
SCREEN_STATE_OFF
Indicates that the screen has changed state and is now off.
|
Int |
SCREEN_STATE_ON
Indicates that the screen has changed state and is now on.
|
Int |
SCROLLBARS_INSIDE_INSET
The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. The scrollbars will not overlap the content area of the view.
|
Int |
SCROLLBARS_INSIDE_OVERLAY
The scrollbar style to display the scrollbars inside the content area, without increasing the padding. The scrollbars will be overlaid with translucency on the view's content.
|
Int |
SCROLLBARS_OUTSIDE_INSET
The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. The scrollbars will only overlap the background, if any.
|
Int |
SCROLLBARS_OUTSIDE_OVERLAY
The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. The scrollbars will be overlaid with translucency.
|
Int |
SCROLLBAR_POSITION_DEFAULT
Position the scroll bar at the default position as determined by the system.
|
Int |
SCROLLBAR_POSITION_LEFT
Position the scroll bar along the left edge.
|
Int |
SCROLLBAR_POSITION_RIGHT
Position the scroll bar along the right edge.
|
Int |
SCROLL_AXIS_HORIZONTAL
Indicates scrolling along the horizontal axis.
|
Int |
SCROLL_AXIS_NONE
Indicates no axis of view scrolling.
|
Int |
SCROLL_AXIS_VERTICAL
Indicates scrolling along the vertical axis.
|
Int |
SCROLL_INDICATOR_BOTTOM
Scroll indicator direction for the bottom edge of the view.
|
Int |
SCROLL_INDICATOR_END
Scroll indicator direction for the ending edge of the view.
Resolved according to the view's layout direction, see getLayoutDirection() for more information.
|
Int |
SCROLL_INDICATOR_LEFT
Scroll indicator direction for the left edge of the view.
|
Int |
SCROLL_INDICATOR_RIGHT
Scroll indicator direction for the right edge of the view.
|
Int |
SCROLL_INDICATOR_START
Scroll indicator direction for the starting edge of the view.
Resolved according to the view's layout direction, see getLayoutDirection() for more information.
|
Int |
SCROLL_INDICATOR_TOP
Scroll indicator direction for the top edge of the view.
|
Int |
SOUND_EFFECTS_ENABLED
View flag indicating whether this view should have sound effects enabled for events such as clicking and touching.
|
Int |
STATUS_BAR_HIDDEN
|
Int |
STATUS_BAR_VISIBLE
|
Int |
SYSTEM_UI_FLAG_FULLSCREEN
Flag for setSystemUiVisibility(int): View has requested to go into the normal fullscreen mode so that its content can take over the screen while still allowing the user to interact with the application.
This has the same visual effect as WindowManager.LayoutParams.FLAG_FULLSCREEN, meaning that non-critical screen decorations (such as the status bar) will be hidden while the user is in the View's window, focusing the experience on that content. Unlike the window flag, if you are using ActionBar in overlay mode with Window#FEATURE_ACTION_BAR_OVERLAY, then enabling this flag will also hide the action bar.
This approach to going fullscreen is best used over the window flag when it is a transient state -- that is, the application does this at certain points in its user interaction where it wants to allow the user to focus on content, but not as a continuous state. For situations where the application would like to simply stay full screen the entire time (such as a game that wants to take over the screen), the window flag is usually a better approach. The state set here will be removed by the system in various situations (such as the user moving to another application) like the other system UI states.
When using this flag, the application should provide some easy facility for the user to go out of it. A common example would be in an e-book reader, where tapping on the screen brings back whatever screen and UI decorations that had been hidden while the user was immersed in reading the book.
|
Int |
SYSTEM_UI_FLAG_HIDE_NAVIGATION
Flag for setSystemUiVisibility(int): View has requested that the system navigation be temporarily hidden.
This is an even less obtrusive state than that called for by SYSTEM_UI_FLAG_LOW_PROFILE; on devices that draw essential navigation controls (Home, Back, and the like) on screen, SYSTEM_UI_FLAG_HIDE_NAVIGATION will cause those to disappear. This is useful (in conjunction with the FLAG_FULLSCREEN and FLAG_LAYOUT_IN_SCREEN window flags) for displaying content using every last pixel on the display.
There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately. When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will be cleared automatically, so that both elements reappear at the same time.
|
Int |
SYSTEM_UI_FLAG_IMMERSIVE
Flag for setSystemUiVisibility(int): View would like to remain interactive when hiding the navigation bar with SYSTEM_UI_FLAG_HIDE_NAVIGATION. If this flag is not set, SYSTEM_UI_FLAG_HIDE_NAVIGATION will be force cleared by the system on any user interaction.
Since this flag is a modifier for SYSTEM_UI_FLAG_HIDE_NAVIGATION, it only has an effect when used in combination with that flag.
|
Int |
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Flag for setSystemUiVisibility(int): View would like to remain interactive when hiding the status bar with SYSTEM_UI_FLAG_FULLSCREEN and/or hiding the navigation bar with SYSTEM_UI_FLAG_HIDE_NAVIGATION. Use this flag to create an immersive experience while also hiding the system bars. If this flag is not set, SYSTEM_UI_FLAG_HIDE_NAVIGATION will be force cleared by the system on any user interaction, and SYSTEM_UI_FLAG_FULLSCREEN will be force-cleared by the system if the user swipes from the top of the screen.
When system bars are hidden in immersive mode, they can be revealed temporarily with system gestures, such as swiping from the top of the screen. These transient system bars will overlay app's content, may have some degree of transparency, and will automatically hide after a short timeout.
Since this flag is a modifier for SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION, it only has an effect when used in combination with one or both of those flags.
|
Int |
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
Flag for setSystemUiVisibility(int): View would like its window to be laid out as if it has requested SYSTEM_UI_FLAG_FULLSCREEN, even if it currently hasn't. This allows it to avoid artifacts when switching in and out of that mode, at the expense that some of its user interface may be covered by screen decorations when they are shown. You can perform layout of your inner UI elements to account for non-fullscreen system UI through the fitSystemWindows(android.graphics.Rect) method.
Note: on displays that have a DisplayCutout, the window may still be placed differently than if SYSTEM_UI_FLAG_FULLSCREEN was set, if the window's WindowManager.LayoutParams#layoutInDisplayCutoutMode is WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT. To avoid this, use either of the other modes.
|
Int |
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
Flag for setSystemUiVisibility(int): View would like its window to be laid out as if it has requested SYSTEM_UI_FLAG_HIDE_NAVIGATION, even if it currently hasn't. This allows it to avoid artifacts when switching in and out of that mode, at the expense that some of its user interface may be covered by screen decorations when they are shown. You can perform layout of your inner UI elements to account for the navigation system UI through the fitSystemWindows(android.graphics.Rect) method.
|
Int |
SYSTEM_UI_FLAG_LAYOUT_STABLE
Flag for setSystemUiVisibility(int): When using other layout flags, we would like a stable view of the content insets given to fitSystemWindows(android.graphics.Rect). This means that the insets seen there will always represent the worst case that the application can expect as a continuous state. In the stock Android UI this is the space for the system bar, nav bar, and status bar, but not more transient elements such as an input method. The stable layout your UI sees is based on the system UI modes you can switch to. That is, if you specify SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN then you will get a stable layout for changes of the SYSTEM_UI_FLAG_FULLSCREEN mode; if you specify SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, then you can transition to SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION with a stable layout. (Note that you should avoid using SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION by itself.) If you have set the window flag WindowManager.LayoutParams#FLAG_FULLSCREEN to hide the status bar (instead of using SYSTEM_UI_FLAG_FULLSCREEN), then a hidden status bar will be considered a "stable" state for purposes here. This allows your UI to continually hide the status bar, while still using the system UI flags to hide the action bar while still retaining a stable layout. Note that changing the window fullscreen flag will never provide a stable layout for a clean transition.
If you are using ActionBar in overlay mode with Window#FEATURE_ACTION_BAR_OVERLAY, this flag will also impact the insets it adds to those given to the application.
|
Int |
SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
Flag for setSystemUiVisibility(int): Requests the navigation bar to draw in a mode that is compatible with light navigation bar backgrounds.
For this to take effect, the window must request FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS but not FLAG_TRANSLUCENT_NAVIGATION.
|
Int |
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
Flag for setSystemUiVisibility(int): Requests the status bar to draw in a mode that is compatible with light status bar backgrounds.
For this to take effect, the window must request FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS but not FLAG_TRANSLUCENT_STATUS.
|
Int |
SYSTEM_UI_FLAG_LOW_PROFILE
Flag for setSystemUiVisibility(int): View has requested the system UI to enter an unobtrusive "low profile" mode.
This is for use in games, book readers, video players, or any other "immersive" application where the usual system chrome is deemed too distracting.
In low profile mode, the status bar and/or navigation icons may dim.
|
Int |
SYSTEM_UI_FLAG_VISIBLE
Special constant for setSystemUiVisibility(int): View has requested the system UI (status bar) to be visible (the default).
|
Int |
SYSTEM_UI_LAYOUT_FLAGS
Flags that can impact the layout in relation to system UI.
|
Int |
TEXT_ALIGNMENT_CENTER
Center the paragraph, e.g. ALIGN_CENTER. Use with setTextAlignment(int)
|
Int |
TEXT_ALIGNMENT_GRAVITY
Default for the root view. The gravity determines the text alignment, ALIGN_NORMAL, ALIGN_CENTER, or ALIGN_OPPOSITE, which are relative to each paragraph's text direction. Use with setTextAlignment(int)
|
Int |
TEXT_ALIGNMENT_INHERIT
Default text alignment. The text alignment of this View is inherited from its parent. Use with setTextAlignment(int)
|
Int |
TEXT_ALIGNMENT_TEXT_END
Align to the end of the paragraph, e.g. ALIGN_OPPOSITE. Use with setTextAlignment(int)
|
Int |
TEXT_ALIGNMENT_TEXT_START
Align to the start of the paragraph, e.g. ALIGN_NORMAL. Use with setTextAlignment(int)
|
Int |
TEXT_ALIGNMENT_VIEW_END
Align to the end of the view, which is ALIGN_RIGHT if the view's resolved layoutDirection is LTR, and ALIGN_LEFT otherwise. Use with setTextAlignment(int)
|
Int |
TEXT_ALIGNMENT_VIEW_START
Align to the start of the view, which is ALIGN_LEFT if the view's resolved layoutDirection is LTR, and ALIGN_RIGHT otherwise. Use with setTextAlignment(int)
|
Int |
TEXT_DIRECTION_ANY_RTL
Text direction is using "any-RTL" algorithm. The paragraph direction is RTL if it contains any strong RTL character, otherwise it is LTR if it contains any strong LTR characters. If there are neither, the paragraph direction is the view's resolved layout direction.
|
Int |
TEXT_DIRECTION_FIRST_STRONG
Text direction is using "first strong algorithm". The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is the view's resolved layout direction.
|
Int |
TEXT_DIRECTION_FIRST_STRONG_LTR
Text direction is using "first strong algorithm". The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is LTR.
|
Int |
TEXT_DIRECTION_FIRST_STRONG_RTL
Text direction is using "first strong algorithm". The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is RTL.
|
Int |
TEXT_DIRECTION_INHERIT
Text direction is inherited through ViewGroup
|
Int |
TEXT_DIRECTION_LOCALE
Text direction is coming from the system Locale.
|
Int |
TEXT_DIRECTION_LTR
Text direction is forced to LTR.
|
Int |
TEXT_DIRECTION_RTL
Text direction is forced to RTL.
|
String |
VIEW_LOG_TAG
The logging tag used by this class with android.util.Log.
|
Int |
VISIBLE
This view is visible. Use with setVisibility and android:visibility.
|
|
Public methods
|
| open Unit |
|
| open Unit |
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.
|
| Unit |
Convenience method to append the specified text to the TextView's display buffer, upgrading it to android.widget.TextView.BufferType#EDITABLE if it was not already editable.
|
| open Unit |
Convenience method to append the specified text slice to the TextView's display buffer, upgrading it to android.widget.TextView.BufferType#EDITABLE if it was not already editable.
|
| open Unit |
|
| open Unit |
|
| open Boolean |
Move the point, specified by the offset, into the view if it is needed.
|
| open Unit |
|
| open Unit |
Use BaseInputConnection#removeComposingSpans to remove any IME composing state from this text view.
|
| open Unit |
|
| open Unit |
|
| open Boolean |
Returns true, only while processing a touch gesture, if the initial touch down event caused focus to move to the text view and as a result its selection changed.
|
| open Unit |
|
| open Unit |
|
| open Boolean |
If this TextView contains editable content, extract a portion of it based on the information in request in to outText.
|
| open Unit |
|
| open CharSequence! |
|
| Int |
Gets the autolink mask of the text.
|
| open Int |
|
| open Int |
|
| open Int |
|
| open IntArray! |
|
| open Int |
Returns the type of auto-size set for this widget.
|
| open Int |
Describes the autofill type of this view, so an android.service.autofill.AutofillService can create the proper AutofillValue when autofilling the view.
|
| open AutofillValue? |
Gets the TextView's current text for AutoFill.
|
| open Int |
|
| open Int |
Gets the current strategy for breaking paragraphs into lines.
|
| open Int |
Returns the padding between the compound drawables and the text.
|
| open BlendMode? |
Returns the blending mode used to apply the tint to the compound drawables, if specified.
|
| open ColorStateList! |
|
| open PorterDuff.Mode! |
Returns the blending mode used to apply the tint to the compound drawables, if specified.
|
| open Array<Drawable!> |
Returns drawables for the left, top, right, and bottom borders.
|
| open Array<Drawable!> |
Returns drawables for the start, top, end, and bottom borders.
|
| open Int |
Returns the bottom padding of the view, plus space for the bottom Drawable if any.
|
| open Int |
Returns the end padding of the view, plus space for the end Drawable if any.
|
| open Int |
Returns the left padding of the view, plus space for the left Drawable if any.
|
| open Int |
Returns the right padding of the view, plus space for the right Drawable if any.
|
| open Int |
Returns the start padding of the view, plus space for the start Drawable if any.
|
| open Int |
Returns the top padding of the view, plus space for the top Drawable if any.
|
| Int |
Return the current color selected to paint the hint text.
|
| Int |
Return the current color selected for normal text.
|
| open ActionMode.Callback! |
Retrieves the value set in setCustomInsertionActionModeCallback.
|
| open ActionMode.Callback! |
Retrieves the value set in setCustomSelectionActionModeCallback.
|
| open Editable! |
Return the text that TextView is displaying as an Editable object.
|
| open TextUtils.TruncateAt! |
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.
|
| open CharSequence! |
Returns the error message that was set to be displayed with setError, or null if no error was set or if it the error was cleared by the widget after user input.
|
| open Int |
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.
|
| open Int |
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.
|
| open Array<InputFilter!>! |
Returns the current list of input filters.
|
| open Int |
Returns the distance between the first text baseline and the top of this TextView.
|
| open Unit |
|
| open String? |
Returns the font feature settings.
|
| open String? |
Returns the font variation settings.
|
| open Boolean |
Return whether this text view is including its entire text contents in frozen icicles.
|
| open Int |
Returns the horizontal and vertical alignment of this TextView.
|
| open Int |
|
| open CharSequence! |
Returns the hint that is displayed when the text of the TextView is empty.
|
| ColorStateList! |
|
| open Int |
Gets the current frequency of automatic hyphenation to be used when determining word breaks.
|
| open Int |
Get the IME action ID previous set with setImeActionLabel.
|
| open CharSequence! |
Get the IME action label previous set with setImeActionLabel.
|
| open LocaleList? |
|
| open Int |
Get the type of the Input Method Editor (IME).
|
| open Boolean |
Gets whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.
|
| open Bundle! |
Retrieve the input extras currently associated with the text view, which can be viewed as well as modified.
|
| open Int |
Get the type of the editable content.
|
| open Int |
|
| KeyListener! |
Gets the current KeyListener for the TextView.
|
| open Int |
Returns the distance between the last text baseline and the bottom of this TextView.
|
| Layout! |
Gets the android.text.Layout that is currently being used to display the text.
|
| open Float |
Gets the text letter-space value, which determines the spacing between characters.
|
| open Int |
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.
|
| open Int |
Return the number of lines of text, or 0 if the internal Layout has not been built.
|
| open Int |
Gets the vertical distance between lines of text, in pixels.
|
| open Float |
Gets the line spacing extra space
|
| open Float |
Gets the line spacing multiplier
|
| ColorStateList! |
|
| Boolean |
Returns whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask has been set to nonzero and links are detected in setText.
|
| open Int |
Gets the number of times the marquee animation is repeated.
|
| open Int |
Returns the maximum width of TextView in terms of ems or -1 if the maximum width was set using setMaxWidth(int) or setWidth(int).
|
| open Int |
Returns the maximum height of TextView in terms of pixels or -1 if the maximum height was set using setMaxLines(int) or setLines(int).
|
| open Int |
Returns the maximum height of TextView in terms of number of lines or -1 if the maximum height was set using setMaxHeight(int) or setHeight(int).
|
| open Int |
Returns the maximum width of TextView in terms of pixels or -1 if the maximum width was set using setMaxEms(int) or setEms(int).
|
| open Int |
Returns the minimum width of TextView in terms of ems or -1 if the minimum width was set using setMinWidth(int) or setWidth(int).
|
| open Int |
Returns the minimum height of TextView in terms of pixels or -1 if the minimum height was set using setMinLines(int) or setLines(int).
|
| open Int |
Returns the minimum height of TextView in terms of number of lines or -1 if the minimum height was set using setMinHeight(int) or setHeight(int).
|
| open Int |
Returns the minimum width of TextView in terms of pixels or -1 if the minimum width was set using setMinEms(int) or setEms(int).
|
| MovementMethod! |
Gets the android.text.method.MovementMethod being used for this TextView, which provides positioning, scrolling, and text selection functionality.
|
| open Int |
Get the character offset closest to the specified absolute position.
|
| open TextPaint! |
Gets the TextPaint used for the text.
|
| open Int |
Gets the flags on the Paint being used to display the text.
|
| open String! |
Get the private type of the content.
|
| open Int |
Convenience for Selection#getSelectionEnd.
|
| open Int |
Convenience for Selection#getSelectionStart.
|
| open Int |
Gets the color of the shadow layer.
|
| open Float |
|
| open Float |
Gets the vertical offset of the shadow layer.
|
| open Float |
Gets the radius of the shadow layer.
|
| Boolean |
Returns whether the soft input method will be made visible when this TextView gets focused.
|
| open CharSequence! |
Return the text that TextView is displaying.
|
| open TextClassifier |
Returns the TextClassifier used by this TextView.
|
| ColorStateList! |
Gets the text colors for the different states (normal, selected, focused) of the TextView.
|
| open Drawable? |
Returns the Drawable corresponding to the text cursor.
|
| open TextDirectionHeuristic |
Returns resolved TextDirectionHeuristic that will be used for text layout.
|
| open Locale |
Get the default primary Locale of the text in this TextView.
|
| open LocaleList |
Get the default LocaleList of the text in this TextView.
|
| open PrecomputedText.Params |
Gets the parameters for text layout precomputation, for use with PrecomputedText.
|
| open Float |
Gets the extent by which text should be stretched horizontally.
|
| open Drawable? |
Returns the Drawable corresponding to the selection handle used for positioning the cursor within text.
|
| open Drawable? |
Returns the Drawable corresponding to the left handle used for selecting text.
|
| open Drawable? |
Returns the Drawable corresponding to the right handle used for selecting text.
|
| open Float |
|
| open Int |
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.
|
| open Int |
Returns the total end padding of the view, including the end Drawable if any.
|
| open Int |
Returns the total left padding of the view, including the left Drawable if any.
|
| open Int |
Returns the total right padding of the view, including the right Drawable if any.
|
| open Int |
Returns the total start padding of the view, including the start Drawable if any.
|
| open Int |
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.
|
| TransformationMethod! |
Gets the current android.text.method.TransformationMethod for the TextView.
|
| open Typeface! |
Gets the current Typeface that is used to style the text.
|
| open Array<URLSpan!>! |
Returns the list of URLSpans attached to the text (by Linkify or otherwise) if any.
|
| open Boolean |
|
| open Boolean |
Return true iff there is a selection of nonzero length inside this text view.
|
| open Unit |
Invalidates the specified Drawable.
|
| open Boolean |
Checks whether the transformation method applied to this TextView is set to ALL CAPS.
|
| open Boolean |
|
| open Boolean |
Get the value of the TextView's elegant height metrics flag.
|
| open Boolean |
|
| Boolean |
Returns whether the text is allowed to be wider than the View.
|
| open Boolean |
Returns whether this text view is a current input method target.
|
| open Boolean |
Returns if the text is constrained to a single horizontally scrolling line ignoring new line characters instead of letting it wrap onto multiple lines.
|
| open Boolean |
Return whether or not suggestions are enabled on this TextView.
|
| open Boolean |
Returns the state of the textIsSelectable flag (See setTextIsSelectable()).
|
| open Unit |
|
| open Int |
Returns the length, in characters, of the text managed by this TextView
|
| open Boolean |
Move the cursor, if needed, so that it is at an offset that is visible to the user.
|
| open Unit |
Called by the framework in response to a request to begin a batch of edit operations through a call to link beginBatchEdit().
|
| open Boolean |
|
| open Unit |
Called by the framework in response to a text completion from the current input method, provided by it calling InputConnection#commitCompletion.
|
| open Unit |
Called by the framework in response to a text auto-correction (such as fixing a typo using a dictionary) from the current input method, provided by it calling InputConnection#commitCorrection(CorrectionInfo).
|
| open InputConnection! |
|
| open Boolean |
|
| open Unit |
Called when an attached input method calls InputConnection#performEditorAction(int) for this text view.
|
| open Unit |
Called by the framework in response to a request to end a batch of edit operations through a call to link endBatchEdit.
|
| open Boolean |
|
| open Boolean |
|
| open Boolean |
|
| open Boolean |
|
| open Boolean |
|
| open Boolean |
|
| open Boolean |
Callback method to be invoked when the view tree is about to be drawn.
|
| open Boolean |
Called by the framework in response to a private command from the current method, provided by it calling InputConnection#performPrivateCommand.
|
| open PointerIcon! |
|
| open Unit |
|
| open Unit |
|
| open Parcelable? |
|
| open Unit |
|
| open Boolean |
Called when a context menu option for the text view is selected.
|
| open Boolean |
|
| open Boolean |
|
| open Unit |
|
| open Boolean |
|
| open Unit |
Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.
|
| open Unit |
|
| open Unit |
Sets the properties of this field to transform input to ALL CAPS display.
|
| Unit |
Sets the autolink mask of the text.
|
| open Unit |
Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds.
|
| open Unit |
Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds.
|
| open Unit |
Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds by using the default auto-size configuration.
|
| open Unit |
Sets the break strategy for breaking paragraphs into lines.
|
| open Unit |
Sets the size of the padding between the compound drawables and the text.
|
| open Unit |
Specifies the blending mode used to apply the tint specified by setCompoundDrawableTintList(android.content.res.ColorStateList) to the compound drawables.
|
| open Unit |
Applies a tint to the compound drawables.
|
| open Unit |
Specifies the blending mode used to apply the tint specified by setCompoundDrawableTintList(android.content.res.ColorStateList) to the compound drawables.
|
| open Unit |
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
|
| open Unit |
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.
|
| open Unit |
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.
|
| open Unit |
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.
|
| open Unit |
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
|
| open Unit |
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
|
| open Unit |
Set whether the cursor is visible.
|
| open Unit |
If provided, this ActionMode.
|
| open Unit |
If provided, this ActionMode.
|
| Unit |
Sets the Factory used to create new Editable.
|
| open Unit |
Set the TextView's elegant height metrics flag.
|
| open Unit |
Causes words in the text that are longer than the view's width to be ellipsized instead of broken in the middle.
|
| open Unit |
Sets the width of the TextView to be exactly ems wide.
|
| open Unit |
|
| open Unit |
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.
|
| open Unit |
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.
|
| open Unit |
Apply to this text view the given extracted text, as previously returned by extractText(android.view.inputmethod.ExtractedTextRequest,android.view.inputmethod.ExtractedText).
|
| open Unit |
Set whether to respect the ascent and descent of the fallback fonts that are used in displaying the text (which is needed to avoid text from consecutive lines running into each other).
|
| open Unit |
Sets the list of input filters that will be used if the buffer is Editable.
|
| open Unit |
Updates the top padding of the TextView so that is the distance between the top of the TextView and first line's baseline.
|
| open Unit |
Sets font feature settings.
|
| open Boolean |
Sets TrueType or OpenType font variation settings.
|
| open Unit |
Control whether this text view saves its entire text contents when freezing to an icicle, in addition to dynamic state such as cursor position.
|
| open Unit |
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.
|
| open Unit |
Sets the height of the TextView to be exactly pixels tall.
|
| open Unit |
Sets the color used to display the selection highlight.
|
| Unit |
Sets the text to be displayed when the text of the TextView is empty.
|
| Unit |
Sets the text to be displayed when the text of the TextView is empty, from a resource.
|
| Unit |
Sets the color of the hint text for all the states (disabled, focussed, selected...) of this TextView.
|
| Unit |
Sets the color of the hint text.
|
| open Unit |
Sets whether the text should be allowed to be wider than the View is.
|
| open Unit |
Sets the frequency of automatic hyphenation to use when determining word breaks.
|
| open Unit |
Change the custom IME action associated with the text view, which will be reported to an IME with EditorInfo#actionLabel and EditorInfo#actionId when it has focus.
|
| open Unit |
Change "hint" locales associated with the text view, which will be reported to an IME with EditorInfo#hintLocales when it has focus.
|
| open Unit |
Change the editor type integer associated with the text view, which is reported to an Input Method Editor (IME) with EditorInfo#imeOptions when it has focus.
|
| open Unit |
Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.
|
| open Unit |
Set the extra input data of the text, which is the EditorInfo#extras Bundle that will be filled in when creating an input connection.
|
| open Unit |
Set the type of the content with a constant as defined for EditorInfo#inputType.
|
| open Unit |
Set justification mode.
|
| open Unit |
Sets the key listener to be used with this TextView.
|
| open Unit |
Updates the bottom padding of the TextView so that is the distance between the bottom of the TextView and the last line's baseline.
|
| open Unit |
Sets text letter-spacing in em units.
|
| open Unit |
Sets an explicit line height for this TextView.
|
| open Unit |
Sets line spacing for this TextView.
|
| open Unit |
Sets the height of the TextView to be exactly lines tall.
|
| Unit |
Sets the color of links in the text.
|
| Unit |
Sets the color of links in the text.
|
| Unit |
Sets whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask has been set to nonzero and links are detected in setText.
|
| open Unit |
Sets how many times to repeat the marquee animation.
|
| open Unit |
Sets the width of the TextView to be at most maxEms wide.
|
| open Unit |
Sets the height of the TextView to be at most maxPixels tall.
|
| open Unit |
Sets the height of the TextView to be at most maxLines tall.
|
| open Unit |
Sets the width of the TextView to be at most maxPixels wide.
|
| open Unit |
Sets the width of the TextView to be at least minEms wide.
|
| open Unit |
Sets the height of the TextView to be at least minPixels tall.
|
| open Unit |
Sets the height of the TextView to be at least minLines tall.
|
| open Unit |
Sets the width of the TextView to be at least minPixels wide.
|
| Unit |
Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.
|
| open Unit |
Set a special listener to be called when an action is performed on the text view.
|
| open Unit |
|
| open Unit |
|
| open Unit |
Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.
|
| open Unit |
Set the private content type of the text, which is the EditorInfo#privateImeOptions field that will be filled in when creating an input connection.
|
| open Unit |
Directly change the content type integer of the text view, without modifying any other state.
|
| open Unit |
Sets the Scroller used for producing a scrolling animation
|
| open Unit |
Set the TextView so that when it takes focus, all the text is selected.
|
| open Unit |
|
| open Unit |
Gives the text a shadow of the specified blur radius and color, the specified distance from its drawn position.
|
| Unit |
Sets whether the soft input method will be made visible when this TextView gets focused.
|
| open Unit |
Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.
|
| open Unit |
If true, sets the properties of this field (number of lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.
|
| Unit |
Sets the Factory used to create new Spannable.
|
| Unit |
Sets the text to be displayed.
|
| open Unit |
Sets the text to be displayed and the android.widget.TextView.BufferType.
|
| Unit |
Sets the TextView to display the specified slice of the specified char array.
|
| Unit |
Sets the text to be displayed using a string resource identifier.
|
| Unit |
Sets the text to be displayed using a string resource identifier and the android.widget.TextView.BufferType.
|
| open Unit |
Sets the text appearance from the specified style resource.
|
| open Unit |
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
|
| open Unit |
Sets the TextClassifier for this TextView.
|
| open Unit |
Sets the text color for all the states (normal, selected, focused) to be this color.
|
| open Unit |
Sets the text color.
|
| open Unit |
Sets the Drawable corresponding to the text cursor.
|
| open Unit |
Sets the Drawable corresponding to the text cursor.
|
| open Unit |
Sets whether the content of this view is selectable by the user.
|
| Unit |
Sets the text to be displayed but retains the cursor position.
|
| Unit |
Sets the text to be displayed and the android.widget.TextView.BufferType but retains the cursor position.
|
| open Unit |
Set the default Locale of the text in this TextView to a one-member LocaleList containing just the given Locale.
|
| open Unit |
Set the default LocaleList of the text in this TextView to the given value.
|
| open Unit |
Apply the text layout parameter.
|
| open Unit |
Sets the horizontal scale factor for text.
|
| open Unit |
Sets the Drawable corresponding to the selection handle used for positioning the cursor within text.
|
| open Unit |
Sets the Drawable corresponding to the selection handle used for positioning the cursor within text.
|
| open Unit |
Sets the Drawable corresponding to the left handle used for selecting text.
|
| open Unit |
Sets the Drawable corresponding to the left handle used for selecting text.
|
| open Unit |
Sets the Drawable corresponding to the right handle used for selecting text.
|
| open Unit |
Sets the Drawable corresponding to the right handle used for selecting text.
|
| open Unit |
Set the default text size to the given value, interpreted as "scaled pixel" units.
|
| open Unit |
Set the default text size to a given unit and value.
|
| Unit |
Sets the transformation that is applied to the text that this TextView is displaying.
|
| open Unit |
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.
|
| open Unit |
Sets the typeface and style in which the text should be displayed.
|
| open Unit |
Sets the width of the TextView to be exactly pixels wide.
|
| open Boolean |
|
| open Boolean |
|
Protected methods
|
| open Int |
|
| open Int |
|
| open Int |
|
| open Unit |
|
| open Int |
|
| open Boolean |
Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.
|
| open MovementMethod! |
Subclasses override this to specify a default movement method.
|
| open Float |
|
| open Int |
|
| open Float |
|
| open Int |
|
| open Int |
|
| open Boolean |
|
| open Unit |
|
| open Unit |
|
| open Unit |
|
| open IntArray! |
|
| open Unit |
|
| open Unit |
|
| open Unit |
|
| open Unit |
|
| open Unit |
|
| open Unit |
This method is called when the selection has changed, in case any subclasses would like to know.
|
| open Unit |
This method is called when the text is changed, in case any subclasses would like to know.
|
| open Unit |
|
| open Boolean |
|
| open Boolean |
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.
|
Inherited functions
|
From class View
Unit |
addChildrenForAccessibility(outChildren: ArrayList<View!>!)
Adds the children of this View relevant for accessibility to the given list as output. Since some Views are not important for accessibility the added child views are not necessarily direct children of this view, rather they are the first level of descendants important for accessibility.
|
Unit |
addFocusables(views: ArrayList<View!>!, direction: Int)
Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. If we are in touch mode, only add views that are also focusable in touch mode.
|
Unit |
addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int)
Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. This method adds all focusable views regardless if we are in touch mode or only views focusable in touch mode if we are in touch mode or only views that can take accessibility focus if accessibility is enabled depending on the focusable mode parameter.
|
Unit |
addKeyboardNavigationClusters(views: MutableCollection<View!>, direction: Int)
Adds any keyboard navigation cluster roots that are descendants of this view (possibly including this view if it is a cluster root itself) to views.
|
Unit |
addOnAttachStateChangeListener(listener: View.OnAttachStateChangeListener!)
Add a listener for attach state changes. This listener will be called whenever this view is attached or detached from a window. Remove the listener using removeOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener).
|
Unit |
addOnLayoutChangeListener(listener: View.OnLayoutChangeListener!)
Add a listener that will be called when the bounds of the view change due to layout processing.
|
Unit |
addOnUnhandledKeyEventListener(listener: View.OnUnhandledKeyEventListener!)
Adds a listener which will receive unhandled KeyEvents. This must be called on the UI thread.
|
Unit |
addTouchables(views: ArrayList<View!>!)
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
|
ViewPropertyAnimator! |
animate()
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
|
Unit |
announceForAccessibility(text: CharSequence!)
Convenience method for sending a AccessibilityEvent#TYPE_ANNOUNCEMENT AccessibilityEvent to suggest that an accessibility service announce the specified text to its users.
Note: The event generated with this API carries no semantic meaning, and is appropriate only in exceptional situations. Apps can generally achieve correct behavior for accessibility by accurately supplying the semantics of their UI. They should not need to specify what exactly is announced to users.
|
Unit |
autofill(values: SparseArray<AutofillValue!>)
Automatically fills the content of the virtual children within this view.
Views with virtual children support the Autofill Framework mainly by:
- Providing the metadata defining what the virtual children mean and how they can be autofilled.
- Implementing the methods that autofill the virtual children.
onProvideAutofillVirtualStructure(android.view.ViewStructure,int) is responsible for the former, this method is responsible for the latter - see autofill(android.view.autofill.AutofillValue) and onProvideAutofillVirtualStructure(android.view.ViewStructure,int) for more info about autofill.
If a child value is updated asynchronously, the next call to AutofillManager#notifyValueChanged(View, int, AutofillValue) must happen after the value was changed to the autofilled value. If not, the child will not be considered autofilled.
Note: To indicate that a virtual view was autofilled, ?android:attr/autofilledHighlight should be drawn over it until the data changes.
|
Boolean |
awakenScrollBars()
Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a default delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.
The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled(). When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate(); in that case the caller should not call invalidate().
This method should be invoked every time a subclass directly updates the scroll parameters.
This method is automatically invoked by scrollBy(int,int) and scrollTo(int,int).
|
Boolean |
awakenScrollBars(startDelay: Int)
Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a fixed delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.
The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled(). When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate(); in that case the caller should not call invalidate().
This method should be invoked every time a subclass directly updates the scroll parameters.
|
Boolean |
awakenScrollBars(startDelay: Int, invalidate: Boolean)
Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a fixed delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.
The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled(). When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate() if the invalidate parameter is set to true; in that case the caller should not call invalidate().
This method should be invoked every time a subclass directly updates the scroll parameters.
|
Unit |
bringToFront()
Change the view's z order in the tree, so it's on top of other sibling views. This ordering change may affect layout, if the parent container uses an order-dependent layout scheme (e.g., LinearLayout). Prior to android.os.Build.VERSION_CODES#KITKAT this method should be followed by calls to requestLayout() and View#invalidate() on the view's parent to force the parent to redraw with the new child ordering.
|
Unit |
buildDrawingCache()
Calling this method is equivalent to calling buildDrawingCache(false).
|
Unit |
buildDrawingCache(autoScale: Boolean)
Forces the drawing cache to be built if the drawing cache is invalid.
If you call buildDrawingCache() manually without calling setDrawingCacheEnabled(true), you should cleanup the cache by calling destroyDrawingCache() afterwards.
Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.
You should avoid calling this method when hardware acceleration is enabled. If you do not need the drawing cache bitmap, calling this method will increase memory usage and cause the view to be rendered in software once, thus negatively impacting performance.
|
Unit |
buildLayer()
Forces this view's layer to be created and this view to be rendered into its layer. If this view's layer type is set to LAYER_TYPE_NONE, invoking this method will have no effect. This method can for instance be used to render a view into its layer before starting an animation. If this view is complex, rendering into the layer before starting the animation will avoid skipping frames.
|
Boolean |
callOnClick()
Directly call any attached OnClickListener. Unlike performClick(), this only calls the listener, and does not do any associated clicking actions like reporting an accessibility event.
|
Boolean |
canResolveLayoutDirection()
Check if layout direction resolution can be done.
|
Boolean |
canResolveTextAlignment()
Check if text alignment resolution can be done.
|
Boolean |
canResolveTextDirection()
Check if text direction resolution can be done.
|
Boolean |
canScrollHorizontally(direction: Int)
Check if this view can be scrolled horizontally in a certain direction.
|
Boolean |
canScrollVertically(direction: Int)
Check if this view can be scrolled vertically in a certain direction.
|
Unit |
cancelDragAndDrop()
Cancels an ongoing drag and drop operation.
A android.view.DragEvent object with android.view.DragEvent#getAction() value of android.view.DragEvent#ACTION_DRAG_ENDED and android.view.DragEvent#getResult() value of false will be sent to every View that received android.view.DragEvent#ACTION_DRAG_STARTED even if they are not currently visible.
This method can be called on any View in the same window as the View on which startDragAndDrop was called.
|
Unit |
cancelPendingInputEvents()
Cancel any deferred high-level input events that were previously posted to the event queue.
Many views post high-level events such as click handlers to the event queue to run deferred in order to preserve a desired user experience - clearing visible pressed states before executing, etc. This method will abort any events of this nature that are currently in flight.
Custom views that generate their own high-level deferred input events should override onCancelPendingInputEvents() and remove those pending events from the queue.
This will also cancel pending input events for any child views.
Note that this may not be sufficient as a debouncing strategy for clicks in all cases. This will not impact newer events posted after this call that may occur as a result of lower-level input events still waiting in the queue. If you are trying to prevent double-submitted events for the duration of some sort of asynchronous transaction you should also take other steps to protect against unexpected double inputs e.g. calling setEnabled(false) and re-enabling the view when the transaction completes, tracking already submitted transaction IDs, etc.
|
Boolean |
checkInputConnectionProxy(view: View!)
Called by the android.view.inputmethod.InputMethodManager when a view who is not the current input connection target is trying to make a call on the manager. The default implementation returns false; you can override this to return true for certain views if you are performing InputConnection proxying to them.
|
Unit |
clearAnimation()
Cancels any animations for this view.
|
Unit |
clearFocus()
Called when this view wants to give up focus. If focus is cleared onFocusChanged(boolean,int,android.graphics.Rect) is called.
Note: When not in touch-mode, the framework will try to give focus to the first focusable View from the top after focus is cleared. Hence, if this View is the first from the top that can take focus, then all callbacks related to clearing focus will be invoked after which the framework will give focus to this view.
|
Int |
combineMeasuredStates(curState: Int, newState: Int)
Merge two states as returned by getMeasuredState().
|
Int |
computeHorizontalScrollExtent()
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollOffset().
The default extent is the drawing width of this view.
|
Int |
computeHorizontalScrollOffset()
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollExtent().
The default offset is the scroll offset of this view.
|
WindowInsets! |
computeSystemWindowInsets(in: WindowInsets!, outLocalInsets: Rect!)
Compute insets that should be consumed by this view and the ones that should propagate to those under it.
|
Int |
computeVerticalScrollOffset()
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollRange() and computeVerticalScrollExtent().
The default offset is the scroll offset of this view.
|
AccessibilityNodeInfo! |
createAccessibilityNodeInfo()
Returns an AccessibilityNodeInfo representing this view from the point of view of an android.accessibilityservice.AccessibilityService. This method is responsible for obtaining an accessibility node info from a pool of reusable instances and calling onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) on this view to initialize the former.
Note: The client is responsible for recycling the obtained instance by calling AccessibilityNodeInfo#recycle() to minimize object creation.
|
Unit |
createContextMenu(menu: ContextMenu!)
Show the context menu for this view. It is not safe to hold on to the menu after returning from this method. You should normally not overload this method. Overload onCreateContextMenu(android.view.ContextMenu) or define an OnCreateContextMenuListener to add items to the context menu.
|
Unit |
destroyDrawingCache()
Frees the resources used by the drawing cache. If you call buildDrawingCache() manually without calling setDrawingCacheEnabled(true), you should cleanup the cache with this method afterwards.
|
WindowInsets! |
dispatchApplyWindowInsets(insets: WindowInsets!)
Request to apply the given window insets to this view or another view in its subtree.
This method should be called by clients wishing to apply insets corresponding to areas obscured by window decorations or overlays. This can include the status and navigation bars, action bars, input methods and more. New inset categories may be added in the future. The method returns the insets provided minus any that were applied by this view or its children.
Clients wishing to provide custom behavior should override the onApplyWindowInsets(android.view.WindowInsets) method or alternatively provide a OnApplyWindowInsetsListener via the setOnApplyWindowInsetsListener method.
This method replaces the older fitSystemWindows method.
|
Boolean |
dispatchCapturedPointerEvent(event: MotionEvent!)
Pass a captured pointer event down to the focused view.
|
Unit |
dispatchConfigurationChanged(newConfig: Configuration!)
Dispatch a notification about a resource configuration change down the view hierarchy. ViewGroups should override to route to their children.
|
Unit |
dispatchDisplayHint(hint: Int)
Dispatch a hint about whether this view is displayed. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.
|
Boolean |
dispatchDragEvent(event: DragEvent!)
Detects if this View is enabled and has a drag event listener. If both are true, then it calls the drag event listener with the android.view.DragEvent it received. If the drag event listener returns true, then dispatchDragEvent() returns true.
For all other cases, the method calls the onDragEvent() drag event handler method and returns its result.
This ensures that a drag event is always consumed, even if the View does not have a drag event listener. However, if the View has a listener and the listener returns true, then onDragEvent() is not called.
|
Unit |
dispatchDraw(canvas: Canvas!)
Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).
|
Unit |
dispatchDrawableHotspotChanged(x: Float, y: Float)
Dispatches drawableHotspotChanged to all of this View's children.
|
Unit |
dispatchFinishTemporaryDetach()
Dispatch onFinishTemporaryDetach() to this View and its direct children if this is a container View. If you override this method you must call through to the superclass implementation.
|
Boolean |
dispatchGenericFocusedEvent(event: MotionEvent!)
Dispatch a generic motion event to the currently focused view.
Do not call this method directly. Call dispatchGenericMotionEvent(android.view.MotionEvent) instead.
|
Boolean |
dispatchGenericMotionEvent(event: MotionEvent!)
Dispatch a generic motion event.
Generic motion events with source class InputDevice#SOURCE_CLASS_POINTER are delivered to the view under the pointer. All other generic motion events are delivered to the focused view. Hover events are handled specially and are delivered to onHoverEvent(android.view.MotionEvent).
|
Boolean |
dispatchGenericPointerEvent(event: MotionEvent!)
Dispatch a generic motion event to the view under the first pointer.
Do not call this method directly. Call dispatchGenericMotionEvent(android.view.MotionEvent) instead.
|
Boolean |
dispatchHoverEvent(event: MotionEvent!)
Dispatch a hover event.
Do not call this method directly. Call dispatchGenericMotionEvent(android.view.MotionEvent) instead.
|
Boolean |
dispatchKeyEvent(event: KeyEvent!)
Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.
|
Boolean |
dispatchKeyEventPreIme(event: KeyEvent!)
Dispatch a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself.
|
Boolean |
dispatchKeyShortcutEvent(event: KeyEvent!)
Dispatches a key shortcut event.
|
Boolean |
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
Dispatch a fling to a nested scrolling parent.
This method should be used to indicate that a nested scrolling child has detected suitable conditions for a fling. Generally this means that a touch scroll has ended with a VelocityTracker in the direction of scrolling that meets or exceeds the ViewConfiguration#getScaledMinimumFlingVelocity() along a scrollable axis.
If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.
|
Boolean |
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
Dispatch a fling to a nested scrolling parent before it is processed by this view.
Nested pre-fling events are to nested fling events what touch intercept is to touch and what nested pre-scroll is to nested scroll. dispatchNestedPreFling offsets an opportunity for the parent view in a nested fling to fully consume the fling before the child view consumes it. If this method returns true, a nested parent view consumed the fling and this view should not scroll as a result.
For a better user experience, only one view in a nested scrolling chain should consume the fling at a time. If a parent view consumed the fling this method will return false. Custom view implementations should account for this in two ways:
- If a custom view is paged and needs to settle to a fixed page-point, do not call
dispatchNestedPreFling; consume the fling and settle to a valid position regardless.
- If a nested parent does consume the fling, this view should not scroll at all, even to settle back to a valid idle position.
Views should also not offer fling velocities to nested parent views along an axis where scrolling is not currently supported; a ScrollView should not offer a horizontal fling velocity to its parents since scrolling along that axis is not permitted and carrying velocity along that motion does not make sense.
|
Boolean |
dispatchNestedPrePerformAccessibilityAction(action: Int, arguments: Bundle!)
Report an accessibility action to this view's parents for delegated processing.
Implementations of performAccessibilityAction(int,android.os.Bundle) may internally call this method to delegate an accessibility action to a supporting parent. If the parent returns true from its ViewParent#onNestedPrePerformAccessibilityAction(View, int, android.os.Bundle) method this method will return true to signify that the action was consumed.
This method is useful for implementing nested scrolling child views. If isNestedScrollingEnabled() returns true and the action is a scrolling action a custom view implementation may invoke this method to allow a parent to consume the scroll first. If this method returns true the custom view should skip its own scrolling behavior.
|
Boolean |
dispatchNestedPreScroll(dx: Int, dy: Int, consumed: IntArray?, offsetInWindow: IntArray?)
Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
Nested pre-scroll events are to nested scroll events what touch intercept is to touch. dispatchNestedPreScroll offers an opportunity for the parent view in a nested scrolling operation to consume some or all of the scroll operation before the child view consumes it.
|
Boolean |
dispatchNestedScroll(dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, offsetInWindow: IntArray?)
Dispatch one step of a nested scroll in progress.
Implementations of views that support nested scrolling should call this to report info about a scroll in progress to the current nested scrolling parent. If a nested scroll is not currently in progress or nested scrolling is not enabled for this view this method does nothing.
Compatible View implementations should also call dispatchNestedPreScroll before consuming a component of the scroll event themselves.
|
Unit |
dispatchPointerCaptureChanged(hasCapture: Boolean)
|
Boolean |
dispatchPopulateAccessibilityEvent(event: AccessibilityEvent!)
Dispatches an AccessibilityEvent to the View first and then to its children for adding their text content to the event. Note that the event text is populated in a separate dispatch path since we add to the event not only the text of the source but also the text of all its descendants. A typical implementation will call onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) on the this view and then call the dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) on each child. Override this method if custom population of the event text content is required.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#dispatchPopulateAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.
Note: Accessibility events of certain types are not dispatched for populating the event text via this method. For details refer to AccessibilityEvent.
|
Unit |
dispatchProvideAutofillStructure(structure: ViewStructure, flags: Int)
Dispatches creation of a ViewStructures for autofill purposes down the hierarchy, when an Assist structure is being created as part of an autofill request.
The default implementation does the following:
Typically, this method should only be overridden by subclasses that provide a view hierarchy (such as ViewGroup) - other classes should override onProvideAutofillStructure(android.view.ViewStructure,int) or onProvideAutofillVirtualStructure(android.view.ViewStructure,int) instead.
When overridden, it must:
- Either call
super.dispatchProvideAutofillStructure(structure, flags) or explicitly set the AutofillId in the structure (for example, by calling structure.setAutofillId(getAutofillId())).
- Decide how to handle the
AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS flag - when set, all views in the structure should be considered important for autofill, regardless of what isImportantForAutofill() returns. We encourage you to respect this flag to provide a better user experience - this flag is typically used when an user explicitly requested autofill. If the flag is not set, then only views marked as important for autofill should be included in the structure - skipping non-important views optimizes the overall autofill performance.
|
Unit |
dispatchProvideStructure(structure: ViewStructure!)
Dispatch creation of ViewStructure down the hierarchy. The default implementation calls onProvideStructure and onProvideVirtualStructure.
|
Unit |
dispatchRestoreInstanceState(container: SparseArray<Parcelable!>!)
Called by restoreHierarchyState(android.util.SparseArray) to retrieve the state for this view and its children. May be overridden to modify how restoring happens to a view's children; for example, some views may want to not store state for their children.
|
Unit |
dispatchSaveInstanceState(container: SparseArray<Parcelable!>!)
Called by saveHierarchyState(android.util.SparseArray) to store the state for this view and its children. May be overridden to modify how freezing happens to a view's children; for example, some views may want to not store state for their children.
|
Unit |
dispatchSetActivated(activated: Boolean)
Dispatch setActivated to all of this View's children.
|
Unit |
dispatchSetPressed(pressed: Boolean)
Dispatch setPressed to all of this View's children.
|
Unit |
dispatchSetSelected(selected: Boolean)
Dispatch setSelected to all of this View's children.
|
Unit |
dispatchStartTemporaryDetach()
Dispatch onStartTemporaryDetach() to this View and its direct children if this is a container View. If you override this method you must call through to the superclass implementation.
|
Unit |
dispatchSystemUiVisibilityChanged(visibility: Int)
Dispatch callbacks to setOnSystemUiVisibilityChangeListener down the view hierarchy.
|
Boolean |
dispatchTouchEvent(event: MotionEvent!)
Pass the touch screen motion event down to the target view, or this view if it is the target.
|
Boolean |
dispatchTrackballEvent(event: MotionEvent!)
Pass a trackball motion event down to the focused view.
|
Boolean |
dispatchUnhandledMove(focused: View!, direction: Int)
This method is the last chance for the focused view and its ancestors to respond to an arrow key. This is called when the focused view did not consume the key internally, nor could the view system find a new view in the requested direction to give focus to.
|
Unit |
dispatchVisibilityChanged(changedView: View, visibility: Int)
Dispatch a view visibility change down the view hierarchy. ViewGroups should override to route to their children.
|
Unit |
dispatchWindowFocusChanged(hasFocus: Boolean)
Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.
|
Unit |
dispatchWindowSystemUiVisiblityChanged(visible: Int)
Dispatch callbacks to onWindowSystemUiVisibilityChanged(int) down the view hierarchy.
|
Unit |
dispatchWindowVisibilityChanged(visibility: Int)
Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.
|
Unit |
draw(canvas: Canvas!)
Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version. If you override this method you must call through to the superclass implementation.
|
View! |
findFocus()
Find the view in the hierarchy rooted at this view that currently has focus.
|
T |
findViewById(id: Int)
Finds the first descendant view with the given ID, the view itself if the ID matches getId(), or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.
Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.
|
T |
findViewWithTag(tag: Any!)
Look for a child view with the given tag. If this view has the given tag, return this view.
|
Boolean |
fitSystemWindows(insets: Rect!)
Called by the view hierarchy when the content insets for a window have changed, to allow it to adjust its content to fit within those windows. The content insets tell you the space that the status bar, input method, and other system windows infringe on the application's window.
You do not normally need to deal with this function, since the default window decoration given to applications takes care of applying it to the content of the window. If you use SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION this will not be the case, and your content can be placed under those system elements. You can then use this method within your view hierarchy if you have parts of your UI which you would like to ensure are not being covered.
The default implementation of this method simply applies the content insets to the view's padding, consuming that content (modifying the insets to be 0), and returning true. This behavior is off by default, but can be enabled through setFitsSystemWindows(boolean).
This function's traversal down the hierarchy is depth-first. The same content insets object is propagated down the hierarchy, so any changes made to it will be seen by all following views (including potentially ones above in the hierarchy since this is a depth-first traversal). The first view that returns true will abort the entire traversal.
The default implementation works well for a situation where it is used with a container that covers the entire window, allowing it to apply the appropriate insets to its content on all edges. If you need a more complicated layout (such as two different views fitting system windows, one on the top of the window, and one on the bottom), you can override the method and handle the insets however you would like. Note that the insets provided by the framework are always relative to the far edges of the window, not accounting for the location of the called view within that window. (In fact when this method is called you do not yet know where the layout will place the view, as it is done before layout happens.)
Note: unlike many View methods, there is no dispatch phase to this call. If you are overriding it in a ViewGroup and want to allow the call to continue to your children, you must be sure to call the super implementation.
Here is a sample layout that makes use of fitting system windows to have controls for a video view placed inside of the window decorations that it hides and shows. This can be used with code like the second sample (video player) shown in setSystemUiVisibility(int).
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">
<view class="com.example.android.apis.view.VideoPlayerActivity$Content" android:id="@+id/content" android:src="@drawable/frantic" android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="center" />
<framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" android:animatelayoutchanges="true">
<textview android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top|center_horizontal" android:textcolor="#ffffffff" android:background="#a0000000" android:textappearance="?android:attr/textAppearanceLarge" android:gravity="left" android:padding="16dp" android:text="A title goes here" />
<button android:id="@+id/play" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:textsize="28dp"></button>
<seekbar android:id="@+id/seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_marginbottom="16dp" />
</framelayout>
</framelayout>
|
View! |
focusSearch(direction: Int)
Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.
|
Unit |
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
Sets the behavior for overlapping rendering for this view (see for more details on this behavior). Calling this method is an alternative to overriding hasOverlappingRendering() in a subclass, providing the value which is then used internally. That is, when is called, the value of is ignored and the value passed into this method is used instead.
|
Unit |
forceLayout()
Forces this view to be laid out during the next layout pass. This method does not call requestLayout() or forceLayout() on the parent.
|
Int |
generateViewId()
Generate a value suitable for use in setId(int). This value will not collide with ID values generated at build time by aapt for R.id.
|
View.AccessibilityDelegate! |
getAccessibilityDelegate()
Returns the delegate for implementing accessibility support via composition. For more details see AccessibilityDelegate.
|
Int |
getAccessibilityLiveRegion()
Gets the live region mode for this View.
|
AccessibilityNodeProvider! |
getAccessibilityNodeProvider()
Gets the provider for managing a virtual view hierarchy rooted at this View and reported to android.accessibilityservice.AccessibilityServices that explore the window content.
If this method returns an instance, this instance is responsible for managing AccessibilityNodeInfos describing the virtual sub-tree rooted at this View including the one representing the View itself. Similarly the returned instance is responsible for performing accessibility actions on any virtual view or the root view itself.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#getAccessibilityNodeProvider(View) is responsible for handling this call.
|
CharSequence? |
getAccessibilityPaneTitle()
Get the title of the pane for purposes of accessibility.
|
Int |
getAccessibilityTraversalAfter()
Gets the id of a view after which this one is visited in accessibility traversal.
|
Int |
getAccessibilityTraversalBefore()
Gets the id of a view before which this one is visited in accessibility traversal.
|
Float |
getAlpha()
The opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
By default this is 1.0f.
|
Animation! |
getAnimation()
Get the animation currently associated with this view.
|
Matrix? |
getAnimationMatrix()
Return the current transformation matrix of the view. This is used in animation frameworks, such as android.transition.Transition. Returns null when there is no transformation provided by setAnimationMatrix(android.graphics.Matrix). Application developers should use transformation methods like setRotation(float), setScaleX(float), setScaleX(float), setTranslationX(float)} and setTranslationY(float) (float)}} instead.
|
IBinder! |
getApplicationWindowToken()
Retrieve a unique token identifying the top-level "real" window of the window that this view is attached to. That is, this is like getWindowToken, except if the window this view in is a panel window (attached to another containing window), then the token of the containing window is returned instead.
|
IntArray |
getAttributeResolutionStack(attribute: Int)
Returns the ordered list of resource ID that are considered when resolving attribute values for this View. The list will include layout resource ID if the View is inflated from XML. It will also include a set of explicit styles if specified in XML using style="...". Finally, it will include the default styles resolved from the theme.
Note: this method will only return actual values if the view attribute debugging is enabled in Android developer options.
|
MutableMap<Int!, Int!> |
getAttributeSourceResourceMap()
Returns the mapping of attribute resource ID to source resource ID where the attribute value was set. Source resource ID can either be a layout resource ID, if the value was set in XML within the View tag, or a style resource ID, if the attribute was set in a style. The source resource value will be one of the resource IDs from getAttributeSourceResourceMap().
Note: this method will only return actual values if the view attribute debugging is enabled in Android developer options.
|
Array<String!>? |
getAutofillHints()
Gets the hints that help an android.service.autofill.AutofillService determine how to autofill the view with the user's data.
See setAutofillHints(java.lang.String...) for more info about these hints.
|
AutofillId! |
getAutofillId()
Gets the unique, logical identifier of this view in the activity, for autofill purposes.
The autofill id is created on demand, unless it is explicitly set by setAutofillId(android.view.autofill.AutofillId).
See setAutofillId(android.view.autofill.AutofillId) for more info.
|
Drawable! |
getBackground()
Gets the background drawable
|
BlendMode? |
getBackgroundTintBlendMode()
Return the blending mode used to apply the tint to the background drawable, if specified.
|
ColorStateList? |
getBackgroundTintList()
Return the tint applied to the background drawable, if specified.
|
PorterDuff.Mode? |
getBackgroundTintMode()
Return the blending mode used to apply the tint to the background drawable, if specified.
|
Int |
getBottom()
Bottom position of this view relative to its parent.
|
Float |
getBottomFadingEdgeStrength()
Returns the strength, or intensity, of the bottom faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
|
Float |
getCameraDistance()
Gets the distance along the Z axis from the camera to this view.
|
Rect! |
getClipBounds()
Returns a copy of the current clipBounds.
|
Boolean |
getClipBounds(outRect: Rect!)
Populates an output rectangle with the clip bounds of the view, returning true if successful or false if the view's clip bounds are null.
|
Boolean |
getClipToOutline()
Returns whether the Outline should be used to clip the contents of the View.
Note that this flag will only be respected if the View's Outline returns true from Outline#canClip().
|
ContentCaptureSession? |
getContentCaptureSession()
Gets the session used to notify content capture events.
|
CharSequence! |
getContentDescription()
Returns the View's content description.
Note: Do not override this method, as it will have no effect on the content description presented to accessibility services. You must call setContentDescription(java.lang.CharSequence) to modify the content description.
|
Context! |
getContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc.
|
ContextMenu.ContextMenuInfo! |
getContextMenuInfo()
Views should implement this if they have extra information to associate with the context menu. The return result is supplied as a parameter to the OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback.
|
Boolean |
getDefaultFocusHighlightEnabled()
/** Returns whether this View should use a default focus highlight when it gets focused but doesn't have android.R.attr#state_focused defined in its background.
|
Int |
getDefaultSize(size: Int, measureSpec: Int)
Utility to return a default size. Uses the supplied size if the MeasureSpec imposed no constraints. Will get larger if allowed by the MeasureSpec.
|
Display! |
getDisplay()
Gets the logical display to which the view's window has been attached.
|
IntArray! |
getDrawableState()
Return an array of resource IDs of the drawable states representing the current state of the view.
|
Bitmap! |
getDrawingCache()
Calling this method is equivalent to calling getDrawingCache(false).
|
Bitmap! |
getDrawingCache(autoScale: Boolean)
Returns the bitmap in which this view drawing is cached. The returned bitmap is null when caching is disabled. If caching is enabled and the cache is not ready, this method will create it. Calling draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling this method and draw it on screen if the returned bitmap is not null.
Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.
|
Int |
getDrawingCacheBackgroundColor()
|
Int |
getDrawingCacheQuality()
Returns the quality of the drawing cache.
|
Unit |
getDrawingRect(outRect: Rect!)
Return the visible drawing bounds of your view. Fills in the output rectangle with the values from getScrollX(), getScrollY(), getWidth(), and getHeight(). These bounds do not account for any transformation properties currently set on the view, such as setScaleX(float) or setRotation(float).
|
Long |
getDrawingTime()
Return the time at which the drawing of the view hierarchy started.
|
Float |
getElevation()
The base elevation of this view relative to its parent, in pixels.
|
Int |
getExplicitStyle()
Returns the resource ID for the style specified using style="..." in the AttributeSet's backing XML element or Resources#ID_NULL otherwise if not specified or otherwise not applicable.
Each View can have an explicit style specified in the layout file. This style is used first during the View attribute resolution, then if an attribute is not defined there the resource system looks at default style and theme as fallbacks.
Note: this method will only return actual values if the view attribute debugging is enabled in Android developer options.
|
Boolean |
getFilterTouchesWhenObscured()
Gets whether the framework should discard touches when the view's window is obscured by another visible window. Refer to the View security documentation for more details.
|
Boolean |
getFitsSystemWindows()
Check for state of setFitsSystemWindows(boolean). If this method returns true, the default implementation of fitSystemWindows(android.graphics.Rect) will be executed.
|
Int |
getFocusable()
Returns the focusable setting for this view.
|
ArrayList<View!>! |
getFocusables(direction: Int)
Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself.
|
Drawable! |
getForeground()
Returns the drawable used as the foreground of this View. The foreground drawable, if non-null, is always drawn on top of the view's content.
|
Int |
getForegroundGravity()
Describes how the foreground is positioned.
|
BlendMode? |
getForegroundTintBlendMode()
Return the blending mode used to apply the tint to the foreground drawable, if specified.
|
ColorStateList? |
getForegroundTintList()
Return the tint applied to the foreground drawable, if specified.
|
PorterDuff.Mode? |
getForegroundTintMode()
Return the blending mode used to apply the tint to the foreground drawable, if specified.
|
Boolean |
getGlobalVisibleRect(r: Rect!, globalOffset: Point!)
If some part of this view is not clipped by any of its parents, then return that area in r in global (root) coordinates. To convert r to local coordinates (without taking possible View rotations into account), offset it by -globalOffset (e.g. r.offset(-globalOffset.x, -globalOffset.y)). If the view is completely clipped or translated out, return false.
|
Boolean |
getGlobalVisibleRect(r: Rect!)
|
Handler! |
getHandler()
|
Boolean |
getHasOverlappingRendering()
Returns the value for overlapping rendering that is used internally. This is either the value passed into forceHasOverlappingRendering(boolean), if called, or the return value of hasOverlappingRendering(), otherwise.
|
Int |
getHeight()
Return the height of your view.
|
Unit |
getHitRect(outRect: Rect!)
Hit rectangle in parent's coordinates
|
Int |
getHorizontalFadingEdgeLength()
Returns the size of the horizontal faded edges used to indicate that more content in this view is visible.
|
Int |
getHorizontalScrollbarHeight()
Returns the height of the horizontal scrollbar.
|
Drawable? |
getHorizontalScrollbarThumbDrawable()
Returns the currently configured Drawable for the thumb of the horizontal scroll bar if it exists, null otherwise.
|
Drawable? |
getHorizontalScrollbarTrackDrawable()
Returns the currently configured Drawable for the track of the horizontal scroll bar if it exists, null otherwise.
|
Int |
getId()
Returns this view's identifier.
|
Int |
getImportantForAccessibility()
Gets the mode for determining whether this View is important for accessibility. A view is important for accessibility if it fires accessibility events and if it is reported to accessibility services that query the screen.
|
Int |
getImportantForAutofill()
Gets the mode for determining whether this view is important for autofill.
See setImportantForAutofill(int) and isImportantForAutofill() for more info about this mode.
|
Boolean |
getKeepScreenOn()
Returns whether the screen should remain on, corresponding to the current value of KEEP_SCREEN_ON.
|
KeyEvent.DispatcherState! |
getKeyDispatcherState()
Return the global KeyEvent.DispatcherState for this view's window. Returns null if the view is not currently attached to the window. Normally you will not need to use this directly, but just use the standard high-level event callbacks like onKeyDown(int,android.view.KeyEvent).
|
Int |
getLabelFor()
Gets the id of a view for which this view serves as a label for accessibility purposes.
|
Int |
getLayerType()
Indicates what type of layer is currently associated with this view. By default a view does not have a layer, and the layer type is LAYER_TYPE_NONE. Refer to the documentation of setLayerType(int,android.graphics.Paint) for more information on the different types of layers.
|
Int |
getLayoutDirection()
Returns the resolved layout direction for this view.
|
ViewGroup.LayoutParams! |
getLayoutParams()
Get the LayoutParams associated with this view. All views should have layout parameters. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children. This method may return null if this View is not attached to a parent ViewGroup or setLayoutParams(android.view.ViewGroup.LayoutParams) was not invoked successfully. When a View is attached to a parent ViewGroup, this method must not return null.
|
Int |
getLeft()
Left position of this view relative to its parent.
|
Boolean |
getLocalVisibleRect(r: Rect!)
|
Unit |
getLocationInSurface(location: IntArray)
Compute the view's coordinate within the surface.
Computes the coordinates of this view in its surface. The argument must be an array of two integers. After the method returns, the array contains the x and y location in that order.
|
Unit |
getLocationInWindow(outLocation: IntArray!)
Computes the coordinates of this view in its window. The argument must be an array of two integers. After the method returns, the array contains the x and y location in that order.
|
Unit |
getLocationOnScreen(outLocation: IntArray!)
Computes the coordinates of this view on the screen. The argument must be an array of two integers. After the method returns, the array contains the x and y location in that order.
|
Matrix! |
getMatrix()
The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.
|
Int |
getMeasuredHeight()
Like getMeasuredHeightAndState(), but only returns the raw height component (that is the result is masked by MEASURED_SIZE_MASK).
|
Int |
getMeasuredHeightAndState()
Return the full height measurement information for this view as computed by the most recent call to measure(int,int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use getHeight() to see how wide a view is after layout.
|
Int |
getMeasuredState()
Return only the state bits of getMeasuredWidthAndState() and getMeasuredHeightAndState(), combined into one integer. The width component is in the regular bits MEASURED_STATE_MASK and the height component is at the shifted bits MEASURED_HEIGHT_STATE_SHIFT>>MEASURED_STATE_MASK.
|
Int |
getMeasuredWidth()
Like getMeasuredWidthAndState(), but only returns the raw width component (that is the result is masked by MEASURED_SIZE_MASK).
|
Int |
getMeasuredWidthAndState()
Return the full width measurement information for this view as computed by the most recent call to measure(int,int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use getWidth() to see how wide a view is after layout.
|
Int |
getMinimumHeight()
Returns the minimum height of the view.
|
Int |
getMinimumWidth()
Returns the minimum width of the view.
|
Int |
getNextClusterForwardId()
Gets the id of the root of the next keyboard navigation cluster.
|
Int |
getNextFocusDownId()
Gets the id of the view to use when the next focus is FOCUS_DOWN.
|
Int |
getNextFocusForwardId()
Gets the id of the view to use when the next focus is FOCUS_FORWARD.
|
Int |
getNextFocusLeftId()
Gets the id of the view to use when the next focus is FOCUS_LEFT.
|
Int |
getNextFocusRightId()
Gets the id of the view to use when the next focus is FOCUS_RIGHT.
|
Int |
getNextFocusUpId()
Gets the id of the view to use when the next focus is FOCUS_UP.
|
View.OnFocusChangeListener! |
getOnFocusChangeListener()
Returns the focus-change callback registered for this view.
|
Int |
getOutlineAmbientShadowColor()
|
ViewOutlineProvider! |
getOutlineProvider()
Returns the current ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
|
Int |
getOutlineSpotShadowColor()
|
Int |
getOverScrollMode()
Returns the over-scroll mode for this view. The result will be one of OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER.
|
ViewOverlay! |
getOverlay()
Returns the overlay for this view, creating it if it does not yet exist. Adding drawables to the overlay will cause them to be displayed whenever the view itself is redrawn. Objects in the overlay should be actively managed: remove them when they should not be displayed anymore. The overlay will always have the same size as its host view.
Note: Overlays do not currently work correctly with SurfaceView or TextureView; contents in overlays for these types of views may not display correctly.
|
Int |
getPaddingBottom()
Returns the bottom padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingEnd()
Returns the end padding of this view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingLeft()
Returns the left padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingRight()
Returns the right padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingStart()
Returns the start padding of this view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingTop()
Returns the top padding of this view.
|
ViewParent! |
getParent()
Gets the parent of this view. Note that the parent is a ViewParent and not necessarily a View.
|
ViewParent! |
getParentForAccessibility()
Gets the parent for accessibility purposes. Note that the parent for accessibility is not necessary the immediate parent. It is the first predecessor that is important for accessibility.
|
Float |
getPivotX()
The x location of the point around which the view is rotated and scaled.
|
Float |
getPivotY()
The y location of the point around which the view is rotated and scaled.
|
PointerIcon! |
getPointerIcon()
Gets the pointer icon for the current view.
|
Resources! |
getResources()
Returns the resources associated with this view.
|
Boolean |
getRevealOnFocusHint()
Returns this view's preference for reveal behavior when it gains focus.
When this method returns true for a child view requesting focus, ancestor views responding to a focus change in ViewParent#requestChildFocus(View, View) should make a best effort to make the newly focused child fully visible to the user. When it returns false, ancestor views should preferably not disrupt scroll positioning or other properties affecting visibility to the user as part of the focus change.
|
Int |
getRight()
Right position of this view relative to its parent.
|
View! |
getRootView()
Finds the topmost view in the current view hierarchy.
|
WindowInsets! |
getRootWindowInsets()
Provide original WindowInsets that are dispatched to the view hierarchy. The insets are only available if the view is attached.
|
Float |
getRotation()
The degrees that the view is rotated around the pivot point.
|
Float |
getRotationX()
The degrees that the view is rotated around the horizontal axis through the pivot point.
|
Float |
getRotationY()
The degrees that the view is rotated around the vertical axis through the pivot point.
|
Float |
getScaleX()
The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1, the default, means that no scaling is applied.
By default, this is 1.0f.
|
Float |
getScaleY()
The amount that the view is scaled in y around the pivot point, as a proportion of the view's unscaled height. A value of 1, the default, means that no scaling is applied.
By default, this is 1.0f.
|
Int |
getScrollBarDefaultDelayBeforeFade()
Returns the delay before scrollbars fade.
|
Int |
getScrollBarFadeDuration()
Returns the scrollbar fade duration.
|
Int |
getScrollBarSize()
Returns the scrollbar size.
|
Int |
getScrollBarStyle()
Returns the current scrollbar style.
|
Int |
getScrollIndicators()
Returns a bitmask representing the enabled scroll indicators.
For example, if the top and left scroll indicators are enabled and all other indicators are disabled, the return value will be View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_LEFT.
To check whether the bottom scroll indicator is enabled, use the value of (getScrollIndicators() & View.SCROLL_INDICATOR_BOTTOM) != 0.
|
Int |
getScrollX()
Return the scrolled left position of this view. This is the left edge of the displayed part of your view. You do not need to draw any pixels farther left, since those are outside of the frame of your view on screen.
|
Int |
getScrollY()
Return the scrolled top position of this view. This is the top edge of the displayed part of your view. You do not need to draw any pixels above it, since those are outside of the frame of your view on screen.
|
Int |
getSolidColor()
Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges. Returning a non-zero color enables the view system to optimize the drawing of the fading edges. If you do return a non-zero color, the alpha should be set to 0xFF.
|
Int |
getSourceLayoutResId()
A View can be inflated from an XML layout. For such Views this method returns the resource ID of the source layout.
|
StateListAnimator! |
getStateListAnimator()
Returns the current StateListAnimator if exists.
|
Int |
getSuggestedMinimumHeight()
Returns the suggested minimum height that the view should use. This returns the maximum of the view's minimum height and the background's minimum height (android.graphics.drawable.Drawable#getMinimumHeight()).
When being used in onMeasure(int,int), the caller should still ensure the returned height is within the requirements of the parent.
|
Int |
getSuggestedMinimumWidth()
Returns the suggested minimum width that the view should use. This returns the maximum of the view's minimum width and the background's minimum width (android.graphics.drawable.Drawable#getMinimumWidth()).
When being used in onMeasure(int,int), the caller should still ensure the returned width is within the requirements of the parent.
|
MutableList<Rect!> |
getSystemGestureExclusionRects()
Retrieve the list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures.
Do not modify the returned list.
|
Int |
getSystemUiVisibility()
Returns the last setSystemUiVisibility(int) that this view has requested.
|
Any! |
getTag()
Returns this view's tag.
|
Any! |
getTag(key: Int)
Returns the tag associated with this view and the specified key.
|
Int |
getTextAlignment()
Return the resolved text alignment.
|
Int |
getTextDirection()
Return the resolved text direction.
|
CharSequence? |
getTooltipText()
Returns the view's tooltip text. Note: Do not override this method, as it will have no effect on the text displayed in the tooltip. You must call setTooltipText(java.lang.CharSequence) to modify the tooltip text.
|
Int |
getTop()
Top position of this view relative to its parent.
|
Float |
getTopFadingEdgeStrength()
Returns the strength, or intensity, of the top faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
|
TouchDelegate! |
getTouchDelegate()
Gets the TouchDelegate for this View.
|
ArrayList<View!>! |
getTouchables()
Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
|
Float |
getTransitionAlpha()
This property is intended only for use by the Fade transition, which animates it to produce a visual translucency that does not side-effect (or get affected by) the real alpha property. This value is composited with the other alpha value (and the AlphaAnimation value, when that is present) to produce a final visual translucency result, which is what is passed into the DisplayList.
|
String! |
getTransitionName()
Returns the name of the View to be used to identify Views in Transitions. Names should be unique in the View hierarchy.
This returns null if the View has not been given a name.
|
Float |
getTranslationX()
The horizontal location of this view relative to its left position. This position is post-layout, in addition to wherever the object's layout placed it.
|
Float |
getTranslationY()
The vertical location of this view relative to its top position. This position is post-layout, in addition to wherever the object's layout placed it.
|
Float |
getTranslationZ()
The depth location of this view relative to its elevation.
|
Long |
getUniqueDrawingId()
Get the identifier used for this view by the drawing system.
|
Int |
getVerticalFadingEdgeLength()
Returns the size of the vertical faded edges used to indicate that more content in this view is visible.
|
Int |
getVerticalScrollbarPosition()
|
Drawable? |
getVerticalScrollbarThumbDrawable()
Returns the currently configured Drawable for the thumb of the vertical scroll bar if it exists, null otherwise.
|
Drawable? |
getVerticalScrollbarTrackDrawable()
Returns the currently configured Drawable for the track of the vertical scroll bar if it exists, null otherwise.
|
Int |
getVerticalScrollbarWidth()
Returns the width of the vertical scrollbar.
|
ViewTreeObserver! |
getViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy. The view tree observer can be used to get notifications when global events, like layout, happen. The returned ViewTreeObserver observer is not guaranteed to remain valid for the lifetime of this View. If the caller of this method keeps a long-lived reference to ViewTreeObserver, it should always check for the return value of ViewTreeObserver#isAlive().
|
Int |
getVisibility()
Returns the visibility status for this view.
|
Int |
getWidth()
Return the width of your view.
|
Int |
getWindowAttachCount()
|
WindowId! |
getWindowId()
Retrieve the WindowId for the window this view is currently attached to.
|
Int |
getWindowSystemUiVisibility()
Returns the current system UI visibility that is currently set for the entire window. This is the combination of the setSystemUiVisibility(int) values supplied by all of the views in the window.
|
IBinder! |
getWindowToken()
Retrieve a unique token identifying the window this view is attached to.
|
Int |
getWindowVisibility()
Returns the current visibility of the window this view is attached to (either GONE, INVISIBLE, or VISIBLE).
|
Unit |
getWindowVisibleDisplayFrame(outRect: Rect!)
Retrieve the overall visible display size in which the window this view is attached to has been positioned in. This takes into account screen decorations above the window, for both cases where the window itself is being position inside of them or the window is being placed under then and covered insets are used for the window to position its content inside. In effect, this tells you the available area where content can be placed and remain visible to users.
This function requires an IPC back to the window manager to retrieve the requested information, so should not be used in performance critical code like drawing.
|
Float |
getX()
The visual x position of this view, in pixels. This is equivalent to the translationX property plus the current left property.
|
Float |
getY()
The visual y position of this view, in pixels. This is equivalent to the translationY property plus the current top property.
|
Float |
getZ()
The visual z position of this view, in pixels. This is equivalent to the translationZ property plus the current elevation property.
|
Boolean |
hasExplicitFocusable()
Returns true if this view is focusable or if it contains a reachable View for which hasExplicitFocusable() returns true. A "reachable hasExplicitFocusable()" is a view whose parents do not block descendants focus. Only VISIBLE views for which getFocusable() would return FOCUSABLE are considered focusable.
This method preserves the pre-Build.VERSION_CODES#O behavior of hasFocusable() in that only views explicitly set focusable will cause this method to return true. A view set to FOCUSABLE_AUTO that resolves to focusable will not.
|
Boolean |
hasFocus()
Returns true if this view has focus itself, or is the ancestor of the view that has focus.
|
Boolean |
hasFocusable()
Returns true if this view is focusable or if it contains a reachable View for which hasFocusable() returns true. A "reachable hasFocusable()" is a view whose parents do not block descendants focus. Only VISIBLE views are considered focusable.
As of Build.VERSION_CODES#O views that are determined to be focusable through FOCUSABLE_AUTO will also cause this method to return true. Apps that declare a android.content.pm.ApplicationInfo#targetSdkVersion of earlier than Build.VERSION_CODES#O will continue to see this method return false for views not explicitly marked as focusable. Use hasExplicitFocusable() if you require the pre-Build.VERSION_CODES#O behavior.
|
Boolean |
hasNestedScrollingParent()
Returns true if this view has a nested scrolling parent.
The presence of a nested scrolling parent indicates that this view has initiated a nested scroll and it was accepted by an ancestor view further up the view hierarchy.
|
Boolean |
hasOnClickListeners()
Return whether this view has an attached OnClickListener. Returns true if there is a listener, false if there is none.
|
Boolean |
hasPointerCapture()
Checks pointer capture status.
|
Boolean |
hasTransientState()
Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible.
A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.
|
Boolean |
hasWindowFocus()
Returns true if this view is in a window that currently has window focus. Note that this is not the same as the view itself having focus.
|
View! |
inflate(context: Context!, resource: Int, root: ViewGroup!)
Inflate a view from an XML resource. This convenience method wraps the LayoutInflater class, which provides a full range of options for view inflation.
|
Unit |
invalidate(dirty: Rect!)
Mark the area defined by dirty as needing to be drawn. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
WARNING: In API 19 and below, this method may be destructive to dirty.
|
Unit |
invalidate(l: Int, t: Int, r: Int, b: Int)
Mark the area defined by the rect (l,t,r,b) as needing to be drawn. The coordinates of the dirty rect are relative to the view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
|
Unit |
invalidate()
Invalidate the whole view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
|
Unit |
invalidateOutline()
Called to rebuild this View's Outline from its ViewOutlineProvider
|
Boolean |
isAccessibilityFocused()
Returns whether this View is accessibility focused.
|
Boolean |
isAccessibilityHeading()
Gets whether this view is a heading for accessibility purposes.
|
Boolean |
isActivated()
Indicates the activation state of this view.
|
Boolean |
isAttachedToWindow()
Returns true if this view is currently attached to a window.
|
Boolean |
isClickable()
Indicates whether this view reacts to click events or not.
|
Boolean |
isContextClickable()
Indicates whether this view reacts to context clicks or not.
|
Boolean |
isDirty()
True if this view has changed since the last time being drawn.
|
Boolean |
isDrawingCacheEnabled()
Indicates whether the drawing cache is enabled for this view.
|
Boolean |
isDuplicateParentStateEnabled()
Indicates whether this duplicates its drawable state from its parent.
|
Boolean |
isEnabled()
Returns the enabled status for this view. The interpretation of the enabled state varies by subclass.
|
Boolean |
isFocusable()
Returns whether this View is currently able to take focus.
|
Boolean |
isFocusableInTouchMode()
When a view is focusable, it may not want to take focus when in touch mode. For example, a button would like focus when the user is navigating via a D-pad so that the user can click on it, but once the user starts touching the screen, the button shouldn't take focus
|
Boolean |
isFocused()
Returns true if this view has focus
|
Boolean |
isFocusedByDefault()
Returns whether this View should receive focus when the focus is restored for the view hierarchy containing this view.
Focus gets restored for a view hierarchy when the root of the hierarchy gets added to a window or serves as a target of cluster navigation.
|
Boolean |
isForceDarkAllowed()
See setForceDarkAllowed(boolean)
|
Boolean |
isHapticFeedbackEnabled()
|
Boolean |
isHardwareAccelerated()
Indicates whether this view is attached to a hardware accelerated window or not.
Even if this method returns true, it does not mean that every call to draw(android.graphics.Canvas) will be made with an hardware accelerated android.graphics.Canvas. For instance, if this view is drawn onto an offscreen android.graphics.Bitmap and its window is hardware accelerated, android.graphics.Canvas#isHardwareAccelerated() will likely return false, and this method will return true.
|
Boolean |
isHorizontalFadingEdgeEnabled()
Indicate whether the horizontal edges are faded when the view is scrolled horizontally.
|
Boolean |
isHorizontalScrollBarEnabled()
Indicate whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Boolean |
isHovered()
Returns true if the view is currently hovered.
|
Boolean |
isImportantForAccessibility()
Computes whether this view should be exposed for accessibility. In general, views that are interactive or provide information are exposed while views that serve only as containers are hidden.
If an ancestor of this view has importance IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, this method returns false.
Otherwise, the value is computed according to the view's getImportantForAccessibility() value:
IMPORTANT_FOR_ACCESSIBILITY_NO or IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, return false
IMPORTANT_FOR_ACCESSIBILITY_YES, return true
IMPORTANT_FOR_ACCESSIBILITY_AUTO, return true if view satisfies any of the following:
- Has an accessibility pane title, see
setAccessibilityPaneTitle
|
Boolean |
isImportantForAutofill()
Hints the Android System whether the android.app.assist.AssistStructure.ViewNode associated with this view is considered important for autofill purposes.
Generally speaking, a view is important for autofill if:
- The view can be autofilled by an
android.service.autofill.AutofillService.
- The view contents can help an
android.service.autofill.AutofillService determine how other views can be autofilled.
For example, view containers should typically return false for performance reasons (since the important info is provided by their children), but if its properties have relevant information (for example, a resource id called credentials, it should return true. On the other hand, views representing labels or editable fields should typically return true, but in some cases they could return false (for example, if they're part of a "Captcha" mechanism).
The value returned by this method depends on the value returned by getImportantForAutofill():
- if it returns
IMPORTANT_FOR_AUTOFILL_YES or IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, then it returns true
- if it returns
IMPORTANT_FOR_AUTOFILL_NO or IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, then it returns false
- if it returns
IMPORTANT_FOR_AUTOFILL_AUTO, then it uses some simple heuristics that can return true in some cases (like a container with a resource id), but false in most.
- otherwise, it returns
false.
When a view is considered important for autofill:
- The view might automatically trigger an autofill request when focused on.
- The contents of the view are included in the
ViewStructure used in an autofill request.
On the other hand, when a view is considered not important for autofill:
|
Boolean |
isInEditMode()
Indicates whether this View is currently in edit mode. A View is usually in edit mode when displayed within a developer tool. For instance, if this View is being drawn by a visual user interface builder, this method should return true. Subclasses should check the return value of this method to provide different behaviors if their normal behavior might interfere with the host environment. For instance: the class spawns a thread in its constructor, the drawing code relies on device-specific features, etc. This method is usually checked in the drawing code of custom widgets.
|
Boolean |
isInLayout()
Returns whether the view hierarchy is currently undergoing a layout pass. This information is useful to avoid situations such as calling requestLayout() during a layout pass.
|
Boolean |
isInTouchMode()
Returns whether the device is currently in touch mode. Touch mode is entered once the user begins interacting with the device by touch, and affects various things like whether focus is always visible to the user.
|
Boolean |
isKeyboardNavigationCluster()
Returns whether this View is a root of a keyboard navigation cluster.
|
Boolean |
isLaidOut()
Returns true if this view has been through at least one layout since it was last attached to or detached from a window.
|
Boolean |
isLayoutDirectionResolved()
|
Boolean |
isLayoutRequested()
Indicates whether or not this view's layout will be requested during the next hierarchy layout pass.
|
Boolean |
isLongClickable()
Indicates whether this view reacts to long click events or not.
|
Boolean |
isNestedScrollingEnabled()
Returns true if nested scrolling is enabled for this view.
If nested scrolling is enabled and this View class implementation supports it, this view will act as a nested scrolling child view when applicable, forwarding data about the scroll operation in progress to a compatible and cooperating nested scrolling parent.
|
Boolean |
isOpaque()
Indicates whether this View is opaque. An opaque View guarantees that it will draw all the pixels overlapping its bounds using a fully opaque color. Subclasses of View should override this method whenever possible to indicate whether an instance is opaque. Opaque Views are treated in a special way by the View hierarchy, possibly allowing it to perform optimizations during invalidate/draw passes.
|
Boolean |
isPaddingRelative()
Return if the padding has been set through relative values setPaddingRelative(int,int,int,int) or through
|
Boolean |
isPivotSet()
Returns whether or not a pivot has been set by a call to setPivotX(float) or setPivotY(float). If no pivot has been set then the pivot will be the center of the view.
|
Boolean |
isPressed()
Indicates whether the view is currently in pressed state. Unless setPressed(boolean) is explicitly called, only clickable views can enter the pressed state.
|
Boolean |
isSaveEnabled()
Indicates whether this view will save its state (that is, whether its onSaveInstanceState method will be called).
|
Boolean |
isSaveFromParentEnabled()
Indicates whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. The default is true; if false, these views will not be saved unless saveHierarchyState(android.util.SparseArray) is called directly on this view.
|
Boolean |
isScreenReaderFocusable()
Returns whether the view should be treated as a focusable unit by screen reader accessibility tools.
|
Boolean |
isScrollContainer()
Indicates whether this view is one of the set of scrollable containers in its window.
|
Boolean |
isScrollbarFadingEnabled()
Returns true if scrollbars will fade when this view is not scrolling
|
Boolean |
isSelected()
Indicates the selection state of this view.
|
Boolean |
isShown()
Returns the visibility of this view and all of its ancestors
|
Boolean |
isSoundEffectsEnabled()
|
Boolean |
isTemporarilyDetached()
Tells whether the View is in the state between onStartTemporaryDetach() and onFinishTemporaryDetach().
This method always returns true when called directly or indirectly from onStartTemporaryDetach(). The return value when called directly or indirectly from onFinishTemporaryDetach(), however, depends on the OS version.
|
Boolean |
isTextAlignmentResolved()
|
Boolean |
isTextDirectionResolved()
|
Boolean |
isVerticalFadingEdgeEnabled()
Indicate whether the vertical edges are faded when the view is scrolled horizontally.
|
Boolean |
isVerticalScrollBarEnabled()
Indicate whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Boolean |
isVisibleToUserForAutofill(virtualId: Int)
Computes whether this virtual autofill view is visible to the user.
Note: By default it returns true, but views providing a virtual hierarchy view must override it.
|
View! |
keyboardNavigationClusterSearch(currentCluster: View!, direction: Int)
Find the nearest keyboard navigation cluster in the specified direction. This does not actually give focus to that cluster.
|
Unit |
layout(l: Int, t: Int, r: Int, b: Int)
Assign a size and position to a view and all of its descendants
This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass().
Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children.
|
Unit |
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
This is called to find out how big a view should be. The parent supplies constraint information in the width and height parameters.
The actual measurement work of a view is performed in onMeasure(int,int), called by this method. Therefore, only onMeasure(int,int) can and must be overridden by subclasses.
|
IntArray! |
mergeDrawableStates(baseState: IntArray!, additionalState: IntArray!)
Merge your own state values in additionalState into the base state values baseState that were returned by onCreateDrawableState(int).
|
Unit |
offsetLeftAndRight(offset: Int)
Offset this view's horizontal location by the specified amount of pixels.
|
Unit |
offsetTopAndBottom(offset: Int)
Offset this view's vertical location by the specified number of pixels.
|
Unit |
onAnimationEnd()
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view. If you override this method, always call super.onAnimationEnd(); If you override this method you must call through to the superclass implementation.
|
Unit |
onAnimationStart()
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view. If you override this method, always call super.onAnimationStart(); If you override this method you must call through to the superclass implementation.
|
WindowInsets! |
onApplyWindowInsets(insets: WindowInsets!)
Called when the view should apply WindowInsets according to its internal policy.
This method should be overridden by views that wish to apply a policy different from or in addition to the default behavior. Clients that wish to force a view subtree to apply insets should call dispatchApplyWindowInsets(android.view.WindowInsets).
Clients may supply an OnApplyWindowInsetsListener to a view. If one is set it will be called during dispatch instead of this method. The listener may optionally call this method from its own implementation if it wishes to apply the view's default insets policy in addition to its own.
Implementations of this method should either return the insets parameter unchanged or a new WindowInsets cloned from the supplied insets with any insets consumed that this view applied itself. This allows new inset types added in future platform versions to pass through existing implementations unchanged without being erroneously consumed.
By default if a view's fitsSystemWindows property is set then the view will consume the system window insets and apply them as padding for the view.
|
Unit |
onCancelPendingInputEvents()
Called as the result of a call to cancelPendingInputEvents() on this view or a parent view.
This method is responsible for removing any pending high-level input events that were posted to the event queue to run later. Custom view classes that post their own deferred high-level events via post(java.lang.Runnable), postDelayed(java.lang.Runnable,long) or android.os.Handler should override this method, call super.onCancelPendingInputEvents() and remove those callbacks as appropriate.
|
Boolean |
onCapturedPointerEvent(event: MotionEvent!)
Implement this method to handle captured pointer events
|
Unit |
onDetachedFromWindow()
This is called when the view is detached from a window. At this point it no longer has a surface for drawing. If you override this method you must call through to the superclass implementation.
|
Unit |
onDisplayHint(hint: Int)
Gives this view a hint about whether is displayed or not. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.
|
Unit |
onDrawForeground(canvas: Canvas!)
Draw any foreground content for this view.
Foreground content may consist of scroll bars, a foreground drawable or other view-specific decorations. The foreground is drawn on top of the primary view content.
|
Unit |
onDrawScrollBars(canvas: Canvas!)
Request the drawing of the horizontal and the vertical scrollbar. The scrollbars are painted only if they have been awakened first.
|
Boolean |
onFilterTouchEventForSecurity(event: MotionEvent!)
Filter the touch event to apply security policies.
|
Unit |
onFinishInflate()
Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.
Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called. If you override this method you must call through to the superclass implementation.
|
Unit |
onFinishTemporaryDetach()
Called after onStartTemporaryDetach when the container is done changing the view.
|
Unit |
onHoverChanged(hovered: Boolean)
Implement this method to handle hover state changes.
This method is called whenever the hover state changes as a result of a call to setHovered.
|
Boolean |
onHoverEvent(event: MotionEvent!)
Implement this method to handle hover events.
This method is called whenever a pointer is hovering into, over, or out of the bounds of a view and the view is not currently being touched. Hover events are represented as pointer events with action MotionEvent#ACTION_HOVER_ENTER, MotionEvent#ACTION_HOVER_MOVE, or MotionEvent#ACTION_HOVER_EXIT.
- The view receives a hover event with action
MotionEvent#ACTION_HOVER_ENTER when the pointer enters the bounds of the view.
- The view receives a hover event with action
MotionEvent#ACTION_HOVER_MOVE when the pointer has already entered the bounds of the view and has moved.
- The view receives a hover event with action
MotionEvent#ACTION_HOVER_EXIT when the pointer has exited the bounds of the view or when the pointer is about to go down due to a button click, tap, or similar user action that causes the view to be touched.
The view should implement this method to return true to indicate that it is handling the hover event, such as by changing its drawable state.
The default implementation calls setHovered to update the hovered state of the view when a hover enter or hover exit event is received, if the view is enabled and is clickable. The default implementation also sends hover accessibility events.
|
Unit |
onInitializeAccessibilityEvent(event: AccessibilityEvent!)
Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.
Example: Setting the password property of an event in addition to properties set by the super implementation:
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
event.setPassword(true);
}
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
If you override this method you must call through to the superclass implementation.
|
Unit |
onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo!)
Initializes an AccessibilityNodeInfo with information about this view. The base implementation sets:
AccessibilityNodeInfo#setParent(View),
AccessibilityNodeInfo#setBoundsInParent(Rect),
AccessibilityNodeInfo#setBoundsInScreen(Rect),
AccessibilityNodeInfo#setPackageName(CharSequence),
AccessibilityNodeInfo#setClassName(CharSequence),
AccessibilityNodeInfo#setContentDescription(CharSequence),
AccessibilityNodeInfo#setEnabled(boolean),
AccessibilityNodeInfo#setClickable(boolean),
AccessibilityNodeInfo#setFocusable(boolean),
AccessibilityNodeInfo#setFocused(boolean),
AccessibilityNodeInfo#setLongClickable(boolean),
AccessibilityNodeInfo#setSelected(boolean),
AccessibilityNodeInfo#setContextClickable(boolean)
Subclasses should override this method, call the super implementation, and set additional attributes.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) is responsible for handling this call.
If you override this method you must call through to the superclass implementation.
|
Boolean |
onKeyLongPress(keyCode: Int, event: KeyEvent!)
Default implementation of KeyEvent.Callback#onKeyLongPress(int, KeyEvent): always returns false (doesn't handle the event).
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
|
Unit |
onOverScrolled(scrollX: Int, scrollY: Int, clampedX: Boolean, clampedY: Boolean)
Called by overScrollBy(int,int,int,int,int,int,int,int,boolean) to respond to the results of an over-scroll operation.
|
Unit |
onPointerCaptureChange(hasCapture: Boolean)
Called when the window has just acquired or lost pointer capture. If you override this method you must call through to the superclass implementation.
|
Unit |
onPopulateAccessibilityEvent(event: AccessibilityEvent!)
Called from dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content. While this method is free to modify event attributes other than text content, doing so should normally be performed in onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent).
Example: Adding formatted date string to an accessibility event in addition to the text added by the super implementation:
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
String selectedDateUtterance = DateUtils.formatDateTime(mContext,
mCurrentDate.getTimeInMillis(), flags);
event.getText().add(selectedDateUtterance);
}
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#onPopulateAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
If you override this method you must call through to the superclass implementation.
|
Unit |
onProvideAutofillStructure(structure: ViewStructure!, flags: Int)
Populates a ViewStructure to fullfil an autofill request.
The structure should contain at least the following properties:
It's also recommended to set the following properties - the more properties the structure has, the higher the changes of an android.service.autofill.AutofillService properly using the structure:
- Autofill hints (
ViewStructure#setAutofillHints(String[])).
- Autofill options (
ViewStructure#setAutofillOptions(CharSequence[])) when the view can only be filled with predefined values (typically used when the autofill type is AUTOFILL_TYPE_LIST).
- Resource id (
ViewStructure#setId(int, String, String, String)).
- Class name (
ViewStructure#setClassName(String)).
- Content description (
ViewStructure#setContentDescription(CharSequence)).
- Visual properties such as visibility (
ViewStructure#setVisibility(int)), dimensions (ViewStructure#setDimens(int, int, int, int, int, int)), and opacity (ViewStructure#setOpaque(boolean)).
- For views representing text fields, text properties such as the text itself (
ViewStructure#setText(CharSequence)), text hints (ViewStructure#setHint(CharSequence), input type (ViewStructure#setInputType(int)),
- For views representing HTML nodes, its web domain (
ViewStructure#setWebDomain(String)) and HTML properties ((ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo)).
The default implementation of this method already sets most of these properties based on related View methods (for example, the autofill id is set using getAutofillId(), the autofill type set using getAutofillType(), etc.), and views in the standard Android widgets library also override it to set their relevant properties (for example, android.widget.TextView already sets the text properties), so it's recommended to only override this method (and call super.onProvideAutofillStructure()) when:
Note: The left and top values set in ViewStructure#setDimens(int, int, int, int, int, int) must be relative to the next ViewGroup#isImportantForAutofill() predecessor view included in the structure.
Views support the Autofill Framework mainly by:
- Providing the metadata defining what the view means and how it can be autofilled.
- Notifying the Android System when the view value changed by calling
AutofillManager#notifyValueChanged(View).
- Implementing the methods that autofill the view.
This method is responsible for the former; autofill(android.view.autofill.AutofillValue) is responsible for the latter.
|
Unit |
onProvideAutofillVirtualStructure(structure: ViewStructure!, flags: Int)
Populates a ViewStructure containing virtual children to fullfil an autofill request.
This method should be used when the view manages a virtual structure under this view. For example, a view that draws input fields using draw(android.graphics.Canvas).
When implementing this method, subclasses must follow the rules below:
- Add virtual children by calling the
ViewStructure#newChild(int) or ViewStructure#asyncNewChild(int) methods, where the id is an unique id identifying the children in the virtual structure.
- The children hierarchy can have multiple levels if necessary, but ideally it should exclude intermediate levels that are irrelevant for autofill; that would improve the autofill performance.
- Also implement
autofill(android.util.SparseArray) to autofill the virtual children.
- Set the autofill properties of the child structure as defined by
onProvideAutofillStructure(android.view.ViewStructure,int), using ViewStructure#setAutofillId(AutofillId, int) to set its autofill id.
- Call
android.view.autofill.AutofillManager#notifyViewEntered(View, int, Rect) and/or android.view.autofill.AutofillManager#notifyViewExited(View, int) when the focused virtual child changed.
- Override
isVisibleToUserForAutofill(int) to allow the platform to query whether a given virtual view is visible to the user in order to support triggering save when all views of interest go away.
- Call
android.view.autofill.AutofillManager#notifyValueChanged(View, int, AutofillValue) when the value of a virtual child changed.
- Call
when the visibility of a virtual child changed.
- Call
android.view.autofill.AutofillManager#notifyViewClicked(View, int) when a virtual child is clicked.
- Call
AutofillManager#commit() when the autofill context of the view structure changed and the current context should be committed (for example, when the user tapped a SUBMIT button in an HTML page).
- Call
AutofillManager#cancel() when the autofill context of the view structure changed and the current context should be canceled (for example, when the user tapped a CANCEL button in an HTML page).
- Provide ways for users to manually request autofill by calling
AutofillManager#requestAutofill(View, int, Rect).
- The
left and top values set in ViewStructure#setDimens(int, int, int, int, int, int) must be relative to the next ViewGroup#isImportantForAutofill() predecessor view included in the structure.
Views with virtual children support the Autofill Framework mainly by:
- Providing the metadata defining what the virtual children mean and how they can be autofilled.
- Implementing the methods that autofill the virtual children.
This method is responsible for the former; autofill(android.util.SparseArray) is responsible for the latter.
|
Unit |
onProvideStructure(structure: ViewStructure!)
Called when assist structure is being retrieved from a view as part of Activity.onProvideAssistData.
|
Unit |
onProvideVirtualStructure(structure: ViewStructure!)
Called when assist structure is being retrieved from a view as part of Activity.onProvideAssistData to generate additional virtual structure under this view. The defaullt implementation uses getAccessibilityNodeProvider() to try to generate this from the view's virtual accessibility nodes, if any. You can override this for a more optimal implementation providing this data.
|
Boolean |
onSetAlpha(alpha: Int)
Invoked if there is a Transform that involves alpha. Subclass that can draw themselves with the specified alpha should return true, and then respect that alpha when their onDraw() is called. If this returns false then the view may be redirected to draw into an offscreen buffer to fulfill the request, which will look fine, but may be slower than if the subclass handles it internally. The default implementation returns false.
|
Unit |
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.
|
Unit |
onStartTemporaryDetach()
This is called when a container is going to temporarily detach a child, with ViewGroup#detachViewFromParent(View). It will either be followed by onFinishTemporaryDetach() or onDetachedFromWindow() when the container is done.
|
Unit |
onVisibilityAggregated(isVisible: Boolean)
Called when the user-visibility of this View is potentially affected by a change to this view itself, an ancestor view or the window this view is attached to. If you override this method you must call through to the superclass implementation.
|
Unit |
onWindowSystemUiVisibilityChanged(visible: Int)
Override to find out when the window's requested system UI visibility has changed, that is the value returned by getWindowSystemUiVisibility(). This is different from the callbacks received through setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener) in that this is only telling you about the local request of the window, not the actual values applied by the system.
|
Unit |
onWindowVisibilityChanged(visibility: Int)
Called when the window containing has change its visibility (between GONE, INVISIBLE, and VISIBLE). Note that this tells you whether or not your window is being made visible to the window manager; this does not tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
|
Boolean |
overScrollBy(deltaX: Int, deltaY: Int, scrollX: Int, scrollY: Int, scrollRangeX: Int, scrollRangeY: Int, maxOverScrollX: Int, maxOverScrollY: Int, isTouchEvent: Boolean)
Scroll the view with standard behavior for scrolling beyond the normal content boundaries. Views that call this method should override onOverScrolled(int,int,boolean,boolean) to respond to the results of an over-scroll operation. Views can use this method to handle any touch or fling-based scrolling.
|
Boolean |
performAccessibilityAction(action: Int, arguments: Bundle!)
Performs the specified accessibility action on the view. For possible accessibility actions look at AccessibilityNodeInfo.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#performAccessibilityAction(View, int, Bundle) is responsible for handling this call.
The default implementation will delegate AccessibilityNodeInfo#ACTION_SCROLL_BACKWARD and AccessibilityNodeInfo#ACTION_SCROLL_FORWARD to nested scrolling parents if nested scrolling is enabled on this view.
|
Boolean |
performClick()
Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.
|
Boolean |
performContextClick(x: Float, y: Float)
Call this view's OnContextClickListener, if it is defined.
|
Boolean |
performContextClick()
Call this view's OnContextClickListener, if it is defined.
|
Boolean |
performHapticFeedback(feedbackConstant: Int)
BZZZTT!!1!
Provide haptic feedback to the user for this view.
The framework will provide haptic feedback for some built in actions, such as long presses, but you may wish to provide feedback for your own widget.
The feedback will only be performed if isHapticFeedbackEnabled() is true.
|
Boolean |
performHapticFeedback(feedbackConstant: Int, flags: Int)
BZZZTT!!1!
Like performHapticFeedback(int), with additional options.
|
Boolean |
performLongClick(x: Float, y: Float)
Calls this view's OnLongClickListener, if it is defined. Invokes the context menu if the OnLongClickListener did not consume the event, anchoring it to an (x,y) coordinate.
|
Unit |
playSoundEffect(soundConstant: Int)
Play a sound effect for this view.
The framework will play sound effects for some built in actions, such as clicking, but you may wish to play these effects in your widget, for instance, for internal navigation.
The sound effect will only be played if sound effects are enabled by the user, and isSoundEffectsEnabled() is true.
|
Boolean |
post(action: Runnable!)
Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread.
|
Boolean |
postDelayed(action: Runnable!, delayMillis: Long)
Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses. The runnable will be run on the user interface thread.
|
Unit |
postInvalidate()
Cause an invalidate to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidate(left: Int, top: Int, right: Int, bottom: Int)
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateDelayed(delayMilliseconds: Long)
Cause an invalidate to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateDelayed(delayMilliseconds: Long, left: Int, top: Int, right: Int, bottom: Int)
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateOnAnimation()
Cause an invalidate to happen on the next animation time step, typically the next display frame.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateOnAnimation(left: Int, top: Int, right: Int, bottom: Int)
Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postOnAnimation(action: Runnable!)
Causes the Runnable to execute on the next animation time step. The runnable will be run on the user interface thread.
|
Unit |
postOnAnimationDelayed(action: Runnable!, delayMillis: Long)
Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. The runnable will be run on the user interface thread.
|
Unit |
refreshDrawableState()
Call this to force a view to update its drawable state. This will cause drawableStateChanged to be called on this view. Views that are interested in the new state should call getDrawableState.
|
Unit |
releasePointerCapture()
Releases the pointer capture.
If the window does not have pointer capture, this call will do nothing.
|
Boolean |
removeCallbacks(action: Runnable!)
Removes the specified Runnable from the message queue.
|
Unit |
removeOnAttachStateChangeListener(listener: View.OnAttachStateChangeListener!)
Remove a listener for attach state changes. The listener will receive no further notification of window attach/detach events.
|
Unit |
removeOnLayoutChangeListener(listener: View.OnLayoutChangeListener!)
Remove a listener for layout changes.
|
Unit |
removeOnUnhandledKeyEventListener(listener: View.OnUnhandledKeyEventListener!)
Removes a listener which will receive unhandled KeyEvents. This must be called on the UI thread.
|
Unit |
requestApplyInsets()
Ask that a new dispatch of onApplyWindowInsets(android.view.WindowInsets) be performed.
|
Unit |
requestFitSystemWindows()
Ask that a new dispatch of fitSystemWindows(android.graphics.Rect) be performed.
|
Boolean |
requestFocus()
Call this to try to give focus to a specific view or to one of its descendants. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it can't be focused due to other conditions (not focusable in touch mode (isFocusableInTouchMode) while the device is in touch mode, not visible, not enabled, or has no size). See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int,android.graphics.Rect) with arguments FOCUS_DOWN and null.
|
Boolean |
requestFocus(direction: Int)
Call this to try to give focus to a specific view or to one of its descendants and give it a hint about what direction focus is heading. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode) while the device is in touch mode. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int,android.graphics.Rect) with null set for the previously focused rectangle.
|
Boolean |
requestFocus(direction: Int, previouslyFocusedRect: Rect!)
Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. The rectangle can help give larger views a finer grained hint about where focus is coming from, and therefore, where to show selection, or forward focus change internally. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode) while the device is in touch mode. A View will not take focus if it is not visible. A View will not take focus if one of its parents has android.view.ViewGroup#getDescendantFocusability() equal to ViewGroup#FOCUS_BLOCK_DESCENDANTS. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. You may wish to override this method if your custom View has an internal View that it wishes to forward the request to.
|
Boolean |
requestFocusFromTouch()
Call this to try to give focus to a specific view or to one of its descendants. This is a special variant of requestFocus() that will allow views that are not focusable in touch mode to request focus when they are touched.
|
Unit |
requestLayout()
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (isInLayout(). If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.
Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.
If you override this method you must call through to the superclass implementation.
|
Unit |
requestPointerCapture()
Requests pointer capture mode.
When the window has pointer capture, the mouse pointer icon will disappear and will not change its position. Further mouse will be dispatched with the source InputDevice#SOURCE_MOUSE_RELATIVE, and relative position changes will be available through MotionEvent#getX and MotionEvent#getY. Non-mouse events (touchscreens, or stylus) will not be affected.
If the window already has pointer capture, this call does nothing.
The capture may be released through releasePointerCapture(), or will be lost automatically when the window loses focus.
|
Boolean |
requestRectangleOnScreen(rectangle: Rect!)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
A View should call this if it maintains some notion of which part of its content is interesting. For example, a text editing view should call this when its cursor moves.
The Rectangle passed into this method should be in the View's content coordinate space. It should not be affected by which part of the View is currently visible or its scroll position.
|
Boolean |
requestRectangleOnScreen(rectangle: Rect!, immediate: Boolean)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
A View should call this if it maintains some notion of which part of its content is interesting. For example, a text editing view should call this when its cursor moves.
The Rectangle passed into this method should be in the View's content coordinate space. It should not be affected by which part of the View is currently visible or its scroll position.
When immediate is set to true, scrolling will not be animated.
|
Unit |
requestUnbufferedDispatch(event: MotionEvent!)
Request unbuffered dispatch of the given stream of MotionEvents to this View. Until this View receives a corresponding MotionEvent#ACTION_UP, ask that the input system not batch MotionEvents but instead deliver them as soon as they're available. This method should only be called for touch events.
This api is not intended for most applications. Buffered dispatch provides many of benefits, and just requesting unbuffered dispatch on most MotionEvent streams will not improve your input latency. Side effects include: increased latency, jittery scrolls and inability to take advantage of system resampling. Talk to your input professional to see if requestUnbufferedDispatch(android.view.MotionEvent) is right for you.
|
T |
requireViewById(id: Int)
Finds the first descendant view with the given ID, the view itself if the ID matches getId(), or throws an IllegalArgumentException if the ID is invalid or there is no matching view in the hierarchy.
Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.
|
Unit |
resetPivot()
Clears any pivot previously set by a call to setPivotX(float) or setPivotY(float). After calling this isPivotSet() will be false and the pivot used for rotation will return to default of being centered on the view.
|
Int |
resolveSize(size: Int, measureSpec: Int)
Version of resolveSizeAndState(int,int,int) returning only the MEASURED_SIZE_MASK bits of the result.
|
Int |
resolveSizeAndState(size: Int, measureSpec: Int, childMeasuredState: Int)
Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. Will take the desired size, unless a different size is imposed by the constraints. The returned value is a compound integer, with the resolved size in the MEASURED_SIZE_MASK bits and optionally the bit MEASURED_STATE_TOO_SMALL set if the resulting size is smaller than the size the view wants to be.
|
Boolean |
restoreDefaultFocus()
Gives focus to the default-focus view in the view hierarchy that has this view as a root. If the default-focus view cannot be found, falls back to calling requestFocus(int).
|
Unit |
restoreHierarchyState(container: SparseArray<Parcelable!>!)
Restore this view hierarchy's frozen state from the given container.
|
Unit |
saveAttributeDataForStyleable(context: Context, styleable: IntArray, attrs: AttributeSet?, t: TypedArray, defStyleAttr: Int, defStyleRes: Int)
Stores debugging information about attributes. This should be called in a constructor by every custom View that uses a custom styleable. If the custom view does not call it, then the custom attributes used by this view will not be visible in layout inspection tools.
|
Unit |
saveHierarchyState(container: SparseArray<Parcelable!>!)
Store this view hierarchy's frozen state into the given container.
|
Unit |
scheduleDrawable(who: Drawable, what: Runnable, when: Long)
Schedules an action on a drawable to occur at a specified time.
|
Unit |
scrollBy(x: Int, y: Int)
Move the scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
scrollTo(x: Int, y: Int)
Set the scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
sendAccessibilityEvent(eventType: Int)
Sends an accessibility event of the given type. If accessibility is not enabled this method has no effect. The default implementation calls onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent) first to populate information about the event source (this View), then calls dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) to populate the text content of the event source including its descendants, and last calls ViewParent#requestSendAccessibilityEvent(View, AccessibilityEvent) on its parent to request sending of the event to interested parties.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#sendAccessibilityEvent(View, int) is responsible for handling this call.
|
Unit |
setAccessibilityDelegate(delegate: View.AccessibilityDelegate?)
Sets a delegate for implementing accessibility support via composition (as opposed to inheritance). For more details, see AccessibilityDelegate.
Note: On platform versions prior to API 23, delegate methods on views in the android.widget.* package are called before host methods. This prevents certain properties such as class name from being modified by overriding AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo), as any changes will be overwritten by the host class.
Starting in API 23, delegate methods are called after host methods, which all properties to be modified without being overwritten by the host class.
|
Unit |
setAccessibilityHeading(isHeading: Boolean)
Set if view is a heading for a section of content for accessibility purposes.
|
Unit |
setAccessibilityLiveRegion(mode: Int)
Sets the live region mode for this view. This indicates to accessibility services whether they should automatically notify the user about changes to the view's content description or text, or to the content descriptions or text of the view's children (where applicable).
For example, in a login screen with a TextView that displays an "incorrect password" notification, that view should be marked as a live region with mode ACCESSIBILITY_LIVE_REGION_POLITE.
To disable change notifications for this view, use ACCESSIBILITY_LIVE_REGION_NONE. This is the default live region mode for most views.
To indicate that the user should be notified of changes, use ACCESSIBILITY_LIVE_REGION_POLITE.
If the view's changes should interrupt ongoing speech and notify the user immediately, use ACCESSIBILITY_LIVE_REGION_ASSERTIVE.
|
Unit |
setAccessibilityPaneTitle(accessibilityPaneTitle: CharSequence?)
Visually distinct portion of a window with window-like semantics are considered panes for accessibility purposes. One example is the content view of a fragment that is replaced. In order for accessibility services to understand a pane's window-like behavior, panes should have descriptive titles. Views with pane titles produce AccessibilityEvents when they appear, disappear, or change title.
|
Unit |
setAccessibilityTraversalAfter(afterId: Int)
Sets the id of a view after which this one is visited in accessibility traversal. A screen-reader must visit the content of the other view before the content of this one. For example, if view B is set to be after view A, then a screen-reader will traverse the entire content of A before traversing the entire content of B, regardles of what traversal strategy it is using.
Views that do not have specified before/after relationships are traversed in order determined by the screen-reader.
Setting that this view is after a view that is not important for accessibility or if this view is not important for accessibility will have no effect as the screen-reader is not aware of unimportant views.
|
Unit |
setAccessibilityTraversalBefore(beforeId: Int)
Sets the id of a view before which this one is visited in accessibility traversal. A screen-reader must visit the content of this view before the content of the one it precedes. For example, if view B is set to be before view A, then a screen-reader will traverse the entire content of B before traversing the entire content of A, regardles of what traversal strategy it is using.
Views that do not have specified before/after relationships are traversed in order determined by the screen-reader.
Setting that this view is before a view that is not important for accessibility or if this view is not important for accessibility will have no effect as the screen-reader is not aware of unimportant views.
|
Unit |
setActivated(activated: Boolean)
Changes the activated state of this view. A view can be activated or not. Note that activation is not the same as selection. Selection is a transient property, representing the view (hierarchy) the user is currently interacting with. Activation is a longer-term state that the user can move views in and out of. For example, in a list view with single or multiple selection enabled, the views in the current selection set are activated. (Um, yeah, we are deeply sorry about the terminology here.) The activated state is propagated down to children of the view it is set on.
|
Unit |
setAlpha(alpha: Float)
Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
Note: setting alpha to a translucent value (0 < alpha < 1) can have significant performance implications, especially for large views. It is best to use the alpha property sparingly and transiently, as in the case of fading animations.
For a view with a frequently changing alpha, such as during a fading animation, it is strongly recommended for performance reasons to either override hasOverlappingRendering() to return false if appropriate, or setting a layer type on the view for the duration of the animation. On versions android.os.Build.VERSION_CODES#M and below, the default path for rendering an unlayered View with alpha could add multiple milliseconds of rendering cost, even for simple or small views. Starting with android.os.Build.VERSION_CODES#M, LAYER_TYPE_HARDWARE is automatically applied to the view at the rendering level.
If this view overrides onSetAlpha(int) to return true, then this view is responsible for applying the opacity itself.
On versions android.os.Build.VERSION_CODES#LOLLIPOP_MR1 and below, note that if the view is backed by a layer and is associated with a layer paint, setting an alpha value less than 1.0 will supersede the alpha of the layer paint.
Starting with android.os.Build.VERSION_CODES#M, setting a translucent alpha value will clip a View to its bounds, unless the View returns false from hasOverlappingRendering.
|
Unit |
setAnimation(animation: Animation!)
Sets the next animation to play for this view. If you want the animation to play immediately, use startAnimation(android.view.animation.Animation) instead. This method provides allows fine-grained control over the start time and invalidation, but you must make sure that 1) the animation has a start time set, and 2) the view's parent (which controls animations on its children) will be invalidated when the animation is supposed to start.
|
Unit |
setAnimationMatrix(matrix: Matrix?)
Changes the transformation matrix on the view. This is used in animation frameworks, such as android.transition.Transition. When the animation finishes, the matrix should be cleared by calling this method with null as the matrix parameter. Application developers should use transformation methods like setRotation(float), setScaleX(float), setScaleX(float), setTranslationX(float)} and setTranslationY(float) (float)}} instead.
|
Unit |
setAutofillHints(vararg autofillHints: String!)
Sets the hints that help an android.service.autofill.AutofillService determine how to autofill the view with the user's data.
Typically, there is only one way to autofill a view, but there could be more than one. For example, if the application accepts either an username or email address to identify an user.
These hints are not validated by the Android System, but passed "as is" to the service. Hence, they can have any value, but it's recommended to use the AUTOFILL_HINT_ constants such as: AUTOFILL_HINT_USERNAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH or AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR.
|
Unit |
setAutofillId(id: AutofillId?)
Sets the unique, logical identifier of this view in the activity, for autofill purposes.
The autofill id is created on demand, and this method should only be called when a view is reused after dispatchProvideAutofillStructure(android.view.ViewStructure,int) is called, as that method creates a snapshot of the view that is passed along to the autofill service.
This method is typically used when view subtrees are recycled to represent different content* —in this case, the autofill id can be saved before the view content is swapped out, and restored later when it's swapped back in. For example:
EditText reusableView = ...;
ViewGroup parentView = ...;
AutofillManager afm = ...;
// Swap out the view and change its contents
AutofillId oldId = reusableView.getAutofillId();
CharSequence oldText = reusableView.getText();
parentView.removeView(reusableView);
AutofillId newId = afm.getNextAutofillId();
reusableView.setText("New I am");
reusableView.setAutofillId(newId);
parentView.addView(reusableView);
// Later, swap the old content back in
parentView.removeView(reusableView);
reusableView.setAutofillId(oldId);
reusableView.setText(oldText);
parentView.addView(reusableView);
|
Unit |
setBackground(background: Drawable!)
Set the background to a given Drawable, or remove the background. If the background has padding, this View's padding is set to the background's padding. However, when a background is removed, this View's padding isn't touched. If setting the padding is desired, please use setPadding(int,int,int,int).
|
Unit |
setBackgroundColor(color: Int)
Sets the background color for this view.
|
Unit |
setBackgroundDrawable(background: Drawable!)
|
Unit |
setBackgroundResource(resid: Int)
Set the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.
|
Unit |
setBackgroundTintBlendMode(blendMode: BlendMode?)
Specifies the blending mode used to apply the tint specified by setBackgroundTintList(android.content.res.ColorStateList)} to the background drawable. The default mode is BlendMode#SRC_IN.
|
Unit |
setBackgroundTintList(tint: ColorStateList?)
Applies a tint to the background drawable. Does not modify the current tint mode, which is BlendMode#SRC_IN by default.
Subsequent calls to setBackground(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable#setTintList(ColorStateList).
|
Unit |
setBackgroundTintMode(tintMode: PorterDuff.Mode?)
Specifies the blending mode used to apply the tint specified by setBackgroundTintList(android.content.res.ColorStateList)} to the background drawable. The default mode is PorterDuff.Mode#SRC_IN.
|
Unit |
setBottom(bottom: Int)
Sets the bottom position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setCameraDistance(distance: Float)
Sets the distance along the Z axis (orthogonal to the X/Y plane on which views are drawn) from the camera to this view. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.
The distance of the camera from the view plane can have an affect on the perspective distortion of the view when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)
The distance is expressed in "depth pixels." The default distance depends on the screen density. For instance, on a medium density display, the default distance is 1280. On a high density display, the default distance is 1920.
If you want to specify a distance that leads to visually consistent results across various densities, use the following formula:
float scale = context.getResources().getDisplayMetrics().density;
view.setCameraDistance(distance * scale);
The density scale factor of a high density display is 1.5, and 1920 = 1280 * 1.5.
|
Unit |
setClickable(clickable: Boolean)
Enables or disables click events for this view. When a view is clickable it will change its state to "pressed" on every click. Subclasses should set the view clickable to visually react to user's clicks.
|
Unit |
setClipBounds(clipBounds: Rect!)
Sets a rectangular area on this view to which the view will be clipped when it is drawn. Setting the value to null will remove the clip bounds and the view will draw normally, using its full bounds.
|
Unit |
setClipToOutline(clipToOutline: Boolean)
Sets whether the View's Outline should be used to clip the contents of the View.
Only a single non-rectangular clip can be applied on a View at any time. Circular clips from a ViewAnimationUtils#createCircularReveal(View, int, int, float, float) animation take priority over Outline clipping, and child Outline clipping takes priority over Outline clipping done by a parent.
Note that this flag will only be respected if the View's Outline returns true from Outline#canClip().
|
Unit |
setContentCaptureSession(contentCaptureSession: ContentCaptureSession?)
Sets the (optional) ContentCaptureSession associated with this view.
This method should be called when you need to associate a ContentCaptureContext to the content capture events associated with this view or its view hierarchy (if it's a ViewGroup).
For example, if your activity is associated with a web domain, first you would need to set the context for the main DOM:
ContentCaptureSession mainSession = rootView.getContentCaptureSession();
mainSession.setContentCaptureContext(ContentCaptureContext.forLocusId(Uri.parse(myUrl));
Then if the page had an IFRAME, you would create a new session for it:
ContentCaptureSession iframeSession = mainSession.createContentCaptureSession(
ContentCaptureContext.forLocusId(Uri.parse(iframeUrl)));
iframeView.setContentCaptureSession(iframeSession);
|
Unit |
setContentDescription(contentDescription: CharSequence!)
Sets the View's content description.
A content description briefly describes the view and is primarily used for accessibility support to determine how a view should be presented to the user. In the case of a view with no textual representation, such as android.widget.ImageButton, a useful content description explains what the view does. For example, an image button with a phone icon that is used to place a call may use "Call" as its content description. An image of a floppy disk that is used to save a file may use "Save".
|
Unit |
setContextClickable(contextClickable: Boolean)
Enables or disables context clicking for this view. This event can launch the listener.
|
Unit |
setDefaultFocusHighlightEnabled(defaultFocusHighlightEnabled: Boolean)
Sets whether this View should use a default focus highlight when it gets focused but doesn't have android.R.attr#state_focused defined in its background.
|
Unit |
setDrawingCacheBackgroundColor(color: Int)
Setting a solid background color for the drawing cache's bitmaps will improve performance and memory usage. Note, though that this should only be used if this view will always be drawn on top of a solid color.
|
Unit |
setDrawingCacheEnabled(enabled: Boolean)
Enables or disables the drawing cache. When the drawing cache is enabled, the next call to getDrawingCache() or buildDrawingCache() will draw the view in a bitmap. Calling draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling getDrawingCache() and draw it on screen if the returned bitmap is not null.
Enabling the drawing cache is similar to setting a layer when hardware acceleration is turned off. When hardware acceleration is turned on, enabling the drawing cache has no effect on rendering because the system uses a different mechanism for acceleration which ignores the flag. If you want to use a Bitmap for the view, even when hardware acceleration is enabled, see setLayerType(int,android.graphics.Paint) for information on how to enable software and hardware layers.
This API can be used to manually generate a bitmap copy of this view, by setting the flag to true and calling getDrawingCache().
|
Unit |
setDrawingCacheQuality(quality: Int)
Set the drawing cache quality of this view. This value is used only when the drawing cache is enabled
|
Unit |
setDuplicateParentStateEnabled(enabled: Boolean)
Enables or disables the duplication of the parent's state into this view. When duplication is enabled, this view gets its drawable state from its parent rather than from its own internal properties.
Note: in the current implementation, setting this property to true after the view was added to a ViewGroup might have no effect at all. This property should always be used from XML or set to true before adding this view to a ViewGroup.
Note: if this view's parent addStateFromChildren property is enabled and this property is enabled, an exception will be thrown.
Note: if the child view uses and updates additional states which are unknown to the parent, these states should not be affected by this method.
|
Unit |
setElevation(elevation: Float)
Sets the base elevation of this view, in pixels.
|
Unit |
setFadingEdgeLength(length: Int)
Set the size of the faded edge used to indicate that more content in this view is available. Will not change whether the fading edge is enabled; use setVerticalFadingEdgeEnabled(boolean) or setHorizontalFadingEdgeEnabled(boolean) to enable the fading edge for the vertical or horizontal fading edges.
|
Unit |
setFilterTouchesWhenObscured(enabled: Boolean)
Sets whether the framework should discard touches when the view's window is obscured by another visible window. Refer to the View security documentation for more details.
|
Unit |
setFitsSystemWindows(fitSystemWindows: Boolean)
Sets whether or not this view should account for system screen decorations such as the status bar and inset its content; that is, controlling whether the default implementation of fitSystemWindows(android.graphics.Rect) will be executed. See that method for more details.
Note that if you are providing your own implementation of fitSystemWindows(android.graphics.Rect), then there is no need to set this flag to true -- your implementation will be overriding the default implementation that checks this flag.
|
Unit |
setFocusable(focusable: Boolean)
Set whether this view can receive the focus.
Setting this to false will also ensure that this view is not focusable in touch mode.
|
Unit |
setFocusable(focusable: Int)
Sets whether this view can receive focus.
Setting this to FOCUSABLE_AUTO tells the framework to determine focusability automatically based on the view's interactivity. This is the default.
Setting this to NOT_FOCUSABLE will ensure that this view is also not focusable in touch mode.
|
Unit |
setFocusableInTouchMode(focusableInTouchMode: Boolean)
Set whether this view can receive focus while in touch mode. Setting this to true will also ensure that this view is focusable.
|
Unit |
setFocusedByDefault(isFocusedByDefault: Boolean)
Sets whether this View should receive focus when the focus is restored for the view hierarchy containing this view.
Focus gets restored for a view hierarchy when the root of the hierarchy gets added to a window or serves as a target of cluster navigation.
|
Unit |
setForceDarkAllowed(allow: Boolean)
Sets whether or not to allow force dark to apply to this view. Setting this to false will disable the auto-dark feature on everything this view draws, including any descendants. Setting this to true will allow this view to be automatically made dark, however a value of 'true' will not override any 'false' value in its parent chain nor will it prevent any 'false' in any of its children. The default behavior of force dark is also influenced by the Theme's isLightTheme attribute. If a theme is isLightTheme="false", then force dark is globally disabled for that theme.
|
Unit |
setForeground(foreground: Drawable!)
Supply a Drawable that is to be rendered on top of all of the content in the view.
|
Unit |
setForegroundGravity(gravity: Int)
Describes how the foreground is positioned. Defaults to START and TOP.
|
Unit |
setForegroundTintBlendMode(blendMode: BlendMode?)
Specifies the blending mode used to apply the tint specified by setForegroundTintList(android.content.res.ColorStateList)} to the background drawable. The default mode is BlendMode#SRC_IN.
|
Unit |
setForegroundTintList(tint: ColorStateList?)
Applies a tint to the foreground drawable. Does not modify the current tint mode, which is PorterDuff.Mode#SRC_IN by default.
Subsequent calls to setForeground(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable#setTintList(ColorStateList).
|
Unit |
setForegroundTintMode(tintMode: PorterDuff.Mode?)
Specifies the blending mode used to apply the tint specified by setForegroundTintList(android.content.res.ColorStateList)} to the background drawable. The default mode is PorterDuff.Mode#SRC_IN.
|
Unit |
setHapticFeedbackEnabled(hapticFeedbackEnabled: Boolean)
Set whether this view should have haptic feedback for events such as long presses.
You may wish to disable haptic feedback if your view already controls its own haptic feedback.
|
Unit |
setHasTransientState(hasTransientState: Boolean)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible. This flag is reference counted, so every call to setHasTransientState(true) should be paired with a later call to setHasTransientState(false).
A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.
|
Unit |
setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled: Boolean)
Define whether the horizontal edges should be faded when this view is scrolled horizontally.
|
Unit |
setHorizontalScrollBarEnabled(horizontalScrollBarEnabled: Boolean)
Define whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Unit |
setHorizontalScrollbarThumbDrawable(drawable: Drawable?)
Defines the horizontal thumb drawable
|
Unit |
setHorizontalScrollbarTrackDrawable(drawable: Drawable?)
Defines the horizontal track drawable
|
Unit |
setHovered(hovered: Boolean)
Sets whether the view is currently hovered.
Calling this method also changes the drawable state of the view. This enables the view to react to hover by using different drawable resources to change its appearance.
The onHoverChanged method is called when the hovered state changes.
|
Unit |
setId(id: Int)
Sets the identifier for this view. The identifier does not have to be unique in this view's hierarchy. The identifier should be a positive number.
|
Unit |
setImportantForAccessibility(mode: Int)
Sets how to determine whether this view is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen.
|
Unit |
setImportantForAutofill(mode: Int)
Sets the mode for determining whether this view is considered important for autofill.
The platform determines the importance for autofill automatically but you can use this method to customize the behavior. For example:
- When the view contents is irrelevant for autofill (for example, a text field used in a "Captcha" challenge), it should be
IMPORTANT_FOR_AUTOFILL_NO.
- When both the view and its children are irrelevant for autofill (for example, the root view of an activity containing a spreadhseet editor), it should be
IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS.
- When the view content is relevant for autofill but its children aren't (for example, a credit card expiration date represented by a custom view that overrides the proper autofill methods and has 2 children representing the month and year), it should be
IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS.
Note: Setting the mode as IMPORTANT_FOR_AUTOFILL_NO or IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS does not guarantee the view (and its children) will be always be considered not important; for example, when the user explicitly makes an autofill request, all views are considered important. See isImportantForAutofill() for more details about how the View's importance for autofill is used.
|
Unit |
setKeepScreenOn(keepScreenOn: Boolean)
Controls whether the screen should remain on, modifying the value of KEEP_SCREEN_ON.
|
Unit |
setKeyboardNavigationCluster(isCluster: Boolean)
Set whether this view is a root of a keyboard navigation cluster.
|
Unit |
setLabelFor(id: Int)
Sets the id of a view for which this view serves as a label for accessibility purposes.
|
Unit |
setLayerPaint(paint: Paint?)
Updates the Paint object used with the current layer (used only if the current layer type is not set to LAYER_TYPE_NONE). Changed properties of the Paint provided to setLayerType(int,android.graphics.Paint) will be used the next time the View is redrawn, but setLayerPaint(android.graphics.Paint) must be called to ensure that the view gets redrawn immediately.
A layer is associated with an optional android.graphics.Paint instance that controls how the layer is composed on screen. The following properties of the paint are taken into account when composing the layer:
If this view has an alpha value set to < 1.0 by calling setAlpha(float), the alpha value of the layer's paint is superseded by this view's alpha value.
|
Unit |
setLayerType(layerType: Int, paint: Paint?)
Specifies the type of layer backing this view. The layer can be LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE.
A layer is associated with an optional android.graphics.Paint instance that controls how the layer is composed on screen. The following properties of the paint are taken into account when composing the layer:
If this view has an alpha value set to < 1.0 by calling setAlpha(float), the alpha value of the layer's paint is superseded by this view's alpha value.
Refer to the documentation of LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE and LAYER_TYPE_HARDWARE for more information on when and how to use layers.
|
Unit |
setLayoutDirection(layoutDirection: Int)
Set the layout direction for this view. This will propagate a reset of layout direction resolution to the view's children and resolve layout direction for this view.
|
Unit |
setLayoutParams(params: ViewGroup.LayoutParams!)
Set the layout parameters associated with this view. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children.
|
Unit |
setLeft(left: Int)
Sets the left position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Assign a size and position to this view. This method is meant to be used in animations only as it applies this position and size for the view only temporary and it can be changed back at any time by the layout.
|
Unit |
setLongClickable(longClickable: Boolean)
Enables or disables long click events for this view. When a view is long clickable it reacts to the user holding down the button for a longer duration than a tap. This event can either launch the listener or a context menu.
|
Unit |
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
This method must be called by onMeasure(int,int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time.
|
Unit |
setMinimumHeight(minHeight: Int)
Sets the minimum height of the view. It is not guaranteed the view will be able to achieve this minimum height (for example, if its parent layout constrains it with less available height).
|
Unit |
setMinimumWidth(minWidth: Int)
Sets the minimum width of the view. It is not guaranteed the view will be able to achieve this minimum width (for example, if its parent layout constrains it with less available width).
|
Unit |
setNestedScrollingEnabled(enabled: Boolean)
Enable or disable nested scrolling for this view.
If this property is set to true the view will be permitted to initiate nested scrolling operations with a compatible parent view in the current hierarchy. If this view does not implement nested scrolling this will have no effect. Disabling nested scrolling while a nested scroll is in progress has the effect of stopping the nested scroll.
|
Unit |
setNextClusterForwardId(nextClusterForwardId: Int)
Sets the id of the view to use as the root of the next keyboard navigation cluster.
|
Unit |
setNextFocusDownId(nextFocusDownId: Int)
Sets the id of the view to use when the next focus is FOCUS_DOWN.
|
Unit |
setNextFocusForwardId(nextFocusForwardId: Int)
Sets the id of the view to use when the next focus is FOCUS_FORWARD.
|
Unit |
setNextFocusLeftId(nextFocusLeftId: Int)
Sets the id of the view to use when the next focus is FOCUS_LEFT.
|
Unit |
setNextFocusRightId(nextFocusRightId: Int)
Sets the id of the view to use when the next focus is FOCUS_RIGHT.
|
Unit |
setNextFocusUpId(nextFocusUpId: Int)
Sets the id of the view to use when the next focus is FOCUS_UP.
|
Unit |
setOnApplyWindowInsetsListener(listener: View.OnApplyWindowInsetsListener!)
Set an OnApplyWindowInsetsListener to take over the policy for applying window insets to this view. The listener's OnApplyWindowInsetsListener#onApplyWindowInsets(View, WindowInsets) method will be called instead of the view's onApplyWindowInsets method.
|
Unit |
setOnCapturedPointerListener(l: View.OnCapturedPointerListener!)
Set a listener to receive callbacks when the pointer capture state of a view changes.
|
Unit |
setOnClickListener(l: View.OnClickListener?)
Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
|
Unit |
setOnContextClickListener(l: View.OnContextClickListener?)
Register a callback to be invoked when this view is context clicked. If the view is not context clickable, it becomes context clickable.
|
Unit |
setOnCreateContextMenuListener(l: View.OnCreateContextMenuListener!)
Register a callback to be invoked when the context menu for this view is being built. If this view is not long clickable, it becomes long clickable.
|
Unit |
setOnDragListener(l: View.OnDragListener!)
Register a drag event listener callback object for this View. The parameter is an implementation of android.view.View.OnDragListener. To send a drag event to a View, the system calls the android.view.View.OnDragListener#onDrag(View,DragEvent) method.
|
Unit |
setOnFocusChangeListener(l: View.OnFocusChangeListener!)
Register a callback to be invoked when focus of this view changed.
|
Unit |
setOnGenericMotionListener(l: View.OnGenericMotionListener!)
Register a callback to be invoked when a generic motion event is sent to this view.
|
Unit |
setOnHoverListener(l: View.OnHoverListener!)
Register a callback to be invoked when a hover event is sent to this view.
|
Unit |
setOnKeyListener(l: View.OnKeyListener!)
Register a callback to be invoked when a hardware key is pressed in this view. Key presses in software input methods will generally not trigger the methods of this listener.
|
Unit |
setOnLongClickListener(l: View.OnLongClickListener?)
Register a callback to be invoked when this view is clicked and held. If this view is not long clickable, it becomes long clickable.
|
Unit |
setOnScrollChangeListener(l: View.OnScrollChangeListener!)
Register a callback to be invoked when the scroll X or Y positions of this view change.
Note: Some views handle scrolling independently from View and may have their own separate listeners for scroll-type events. For example, ListView allows clients to register an AbsListView.OnScrollListener to listen for changes in list scroll position.
|
Unit |
setOnSystemUiVisibilityChangeListener(l: View.OnSystemUiVisibilityChangeListener!)
Set a listener to receive callbacks when the visibility of the system bar changes.
|
Unit |
setOnTouchListener(l: View.OnTouchListener!)
Register a callback to be invoked when a touch event is sent to this view.
|
Unit |
setOutlineAmbientShadowColor(color: Int)
Sets the color of the ambient shadow that is drawn when the view has a positive Z or elevation value.
By default the shadow color is black. Generally, this color will be opaque so the intensity of the shadow is consistent between different views with different colors.
The opacity of the final ambient shadow is a function of the shadow caster height, the alpha channel of the outlineAmbientShadowColor (typically opaque), and the android.R.attr#ambientShadowAlpha theme attribute.
|
Unit |
setOutlineProvider(provider: ViewOutlineProvider!)
Sets the ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
The default ViewOutlineProvider, ViewOutlineProvider#BACKGROUND, queries the Outline from the View's background drawable, via Drawable#getOutline(Outline). Changing the outline provider with this method allows this behavior to be overridden.
If the ViewOutlineProvider is null, if querying it for an outline returns false, or if the produced Outline is Outline#isEmpty(), shadows will not be cast.
Only outlines that return true from Outline#canClip() may be used for clipping.
|
Unit |
setOutlineSpotShadowColor(color: Int)
Sets the color of the spot shadow that is drawn when the view has a positive Z or elevation value.
By default the shadow color is black. Generally, this color will be opaque so the intensity of the shadow is consistent between different views with different colors.
The opacity of the final spot shadow is a function of the shadow caster height, the alpha channel of the outlineSpotShadowColor (typically opaque), and the android.R.attr#spotShadowAlpha theme attribute.
|
Unit |
setOverScrollMode(overScrollMode: Int)
Set the over-scroll mode for this view. Valid over-scroll modes are OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER. Setting the over-scroll mode of a view will have an effect only if the view is capable of scrolling.
|
Unit |
setPivotX(pivotX: Float)
Sets the x location of the point around which the view is rotated and scaled. By default, the pivot point is centered on the object. Setting this property disables this behavior and causes the view to use only the explicitly set pivotX and pivotY values.
|
Unit |
setPivotY(pivotY: Float)
Sets the y location of the point around which the view is rotated and scaled. By default, the pivot point is centered on the object. Setting this property disables this behavior and causes the view to use only the explicitly set pivotX and pivotY values.
|
Unit |
setPointerIcon(pointerIcon: PointerIcon!)
Set the pointer icon for the current view. Passing null will restore the pointer icon to its default value.
|
Unit |
setPressed(pressed: Boolean)
Sets the pressed state for this view.
|
Unit |
setRevealOnFocusHint(revealOnFocus: Boolean)
Sets this view's preference for reveal behavior when it gains focus.
When set to true, this is a signal to ancestor views in the hierarchy that this view would prefer to be brought fully into view when it gains focus. For example, a text field that a user is meant to type into. Other views such as scrolling containers may prefer to opt-out of this behavior.
The default value for views is true, though subclasses may change this based on their preferred behavior.
|
Unit |
setRight(right: Int)
Sets the right position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setRotation(rotation: Float)
Sets the degrees that the view is rotated around the pivot point. Increasing values result in clockwise rotation.
|
Unit |
setRotationX(rotationX: Float)
Sets the degrees that the view is rotated around the horizontal axis through the pivot point. Increasing values result in clockwise rotation from the viewpoint of looking down the x axis. When rotating large views, it is recommended to adjust the camera distance accordingly. Refer to setCameraDistance(float) for more information.
|
Unit |
setRotationY(rotationY: Float)
Sets the degrees that the view is rotated around the vertical axis through the pivot point. Increasing values result in counter-clockwise rotation from the viewpoint of looking down the y axis. When rotating large views, it is recommended to adjust the camera distance accordingly. Refer to setCameraDistance(float) for more information.
|
Unit |
setSaveEnabled(enabled: Boolean)
Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState method will be called). Note that even if freezing is enabled, the view still must have an id assigned to it (via setId(int)) for its state to be saved. This flag can only disable the saving of this view; any child views may still have their state saved.
|
Unit |
setSaveFromParentEnabled(enabled: Boolean)
Controls whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. The default is true; if false, these views will not be saved unless saveHierarchyState(android.util.SparseArray) is called directly on this view.
|
Unit |
setScaleX(scaleX: Float)
Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.
|
Unit |
setScaleY(scaleY: Float)
Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.
|
Unit |
setScreenReaderFocusable(screenReaderFocusable: Boolean)
Sets whether this View should be a focusable element for screen readers and include non-focusable Views from its subtree when providing feedback.
Note: this is similar to using android:focusable, but does not impact input focus behavior.
|
Unit |
setScrollBarDefaultDelayBeforeFade(scrollBarDefaultDelayBeforeFade: Int)
Define the delay before scrollbars fade.
|
Unit |
setScrollBarFadeDuration(scrollBarFadeDuration: Int)
Define the scrollbar fade duration.
|
Unit |
setScrollBarSize(scrollBarSize: Int)
Define the scrollbar size.
|
Unit |
setScrollBarStyle(style: Int)
Specify the style of the scrollbars. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding, then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.
|
Unit |
setScrollContainer(isScrollContainer: Boolean)
Change whether this view is one of the set of scrollable containers in its window. This will be used to determine whether the window can resize or must pan when a soft input area is open -- scrollable containers allow the window to use resize mode since the container will appropriately shrink.
|
Unit |
setScrollIndicators(indicators: Int)
Sets the state of all scroll indicators.
See setScrollIndicators(int,int) for usage information.
|
Unit |
setScrollIndicators(indicators: Int, mask: Int)
Sets the state of the scroll indicators specified by the mask. To change all scroll indicators at once, see setScrollIndicators(int).
When a scroll indicator is enabled, it will be displayed if the view can scroll in the direction of the indicator.
Multiple indicator types may be enabled or disabled by passing the logical OR of the desired types. If multiple types are specified, they will all be set to the same enabled state.
For example, to enable the top scroll indicatorExample: setScrollIndicators indicators the indicator direction, or the logical OR of multiple indicator directions. One or more of: <ul> <li>{ #SCROLL_INDICATOR_TOP}</li> <li>{ #SCROLL_INDICATOR_BOTTOM}</li> <li>{ #SCROLL_INDICATOR_LEFT}</li> <li>{ #SCROLL_INDICATOR_RIGHT}</li> <li>{ #SCROLL_INDICATOR_START}</li> <li>{ #SCROLL_INDICATOR_END}</li> </ul> #setScrollIndicators(int) #getScrollIndicators() ref android.R.styleable#View_scrollIndicators indicators Value is either <code>0</code> or a combination of { android.view.View#SCROLL_INDICATOR_TOP}, { android.view.View#SCROLL_INDICATOR_BOTTOM}, { android.view.View#SCROLL_INDICATOR_LEFT}, { android.view.View#SCROLL_INDICATOR_RIGHT}, { android.view.View#SCROLL_INDICATOR_START}, and { android.view.View#SCROLL_INDICATOR_END} mask Value is either <code>0</code> or a combination of { android.view.View#SCROLL_INDICATOR_TOP}, { android.view.View#SCROLL_INDICATOR_BOTTOM}, { android.view.View#SCROLL_INDICATOR_LEFT}, { android.view.View#SCROLL_INDICATOR_RIGHT}, { android.view.View#SCROLL_INDICATOR_START}, and { android.view.View#SCROLL_INDICATOR_END} 23
|
Unit |
setScrollX(value: Int)
Set the horizontal scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
setScrollY(value: Int)
Set the vertical scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
setScrollbarFadingEnabled(fadeScrollbars: Boolean)
Define whether scrollbars will fade when the view is not scrolling.
|
Unit |
setSoundEffectsEnabled(soundEffectsEnabled: Boolean)
Set whether this view should have sound effects enabled for events such as clicking and touching.
You may wish to disable sound effects for a view if you already play sounds, for instance, a dial key that plays dtmf tones.
|
Unit |
setStateListAnimator(stateListAnimator: StateListAnimator!)
Attaches the provided StateListAnimator to this View.
Any previously attached StateListAnimator will be detached.
|
Unit |
setSystemGestureExclusionRects(rects: MutableList<Rect!>)
Sets a list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures. This method should be called by onLayout(boolean,int,int,int,int) or onDraw(android.graphics.Canvas).
Use this to tell the system which specific sub-areas of a view need to receive gesture input in order to function correctly in the presence of global system gestures that may conflict. For example, if the system wishes to capture swipe-in-from-screen-edge gestures to provide system-level navigation functionality, a view such as a navigation drawer container can mark the left (or starting) edge of itself as requiring gesture capture priority using this API. The system may then choose to relax its own gesture recognition to allow the app to consume the user's gesture. It is not necessary for an app to register exclusion rects for broadly spanning regions such as the entirety of a ScrollView or for simple press and release click targets such as Button. Mark an exclusion rect when interacting with a view requires a precision touch gesture in a small area in either the X or Y dimension, such as an edge swipe or dragging a SeekBar thumb.
Do not modify the provided list after this method is called.
Note: the system will put a limit of 200dp on the vertical extent of the exclusions it takes into account. The limit does not apply while the navigation bar is stickily hidden, nor to the input method and Intent#CATEGORY_HOME.
|
Unit |
setSystemUiVisibility(visibility: Int)
Request that the visibility of the status bar or other screen/window decorations be changed.
This method is used to put the over device UI into temporary modes where the user's attention is focused more on the application content, by dimming or hiding surrounding system affordances. This is typically used in conjunction with Window#FEATURE_ACTION_BAR_OVERLAY, allowing the applications content to be placed behind the action bar (and with these flags other system affordances) so that smooth transitions between hiding and showing them can be done.
Two representative examples of the use of system UI visibility is implementing a content browsing application (like a magazine reader) and a video playing application.
The first code shows a typical implementation of a View in a content browsing application. In this implementation, the application goes into a content-oriented mode by hiding the status bar and action bar, and putting the navigation elements into lights out mode. The user can then interact with content while in this mode. Such an application should provide an easy way for the user to toggle out of the mode (such as to check information in the status bar or access notifications). In the implementation here, this is done simply by tapping on the content.
public static class Content extends ScrollView
implements View.OnSystemUiVisibilityChangeListener, View.OnClickListener {
TextView mText;
TextView mTitleView;
SeekBar mSeekView;
boolean mNavVisible;
int mBaseSystemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| SYSTEM_UI_FLAG_LAYOUT_STABLE;
int mLastSystemUiVis;
Runnable mNavHider = new Runnable() {
@Override public void run() {
setNavVisibility(false);
}
};
public Content(Context context, AttributeSet attrs) {
super(context, attrs);
mText = new TextView(context);
mText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
mText.setText(context.getString(R.string.alert_dialog_two_buttons2ultra_msg));
mText.setClickable(false);
mText.setOnClickListener(this);
mText.setTextIsSelectable(true);
addView(mText, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
setOnSystemUiVisibilityChangeListener(this);
}
public void init(TextView title, SeekBar seek) {
// This called by the containing activity to supply the surrounding
// state of the content browser that it will interact with.
mTitleView = title;
mSeekView = seek;
setNavVisibility(true);
}
@Override public void onSystemUiVisibilityChange(int visibility) {
// Detect when we go out of low-profile mode, to also go out
// of full screen. We only do this when the low profile mode
// is changing from its last state, and turning off.
int diff = mLastSystemUiVis ^ visibility;
mLastSystemUiVis = visibility;
if ((diff&SYSTEM_UI_FLAG_LOW_PROFILE) != 0
&& (visibility&SYSTEM_UI_FLAG_LOW_PROFILE) == 0) {
setNavVisibility(true);
}
}
@Override protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
// When we become visible, we show our navigation elements briefly
// before hiding them.
setNavVisibility(true);
getHandler().postDelayed(mNavHider, 2000);
}
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
// When the user scrolls, we hide navigation elements.
setNavVisibility(false);
}
@Override public void onClick(View v) {
// When the user clicks, we toggle the visibility of navigation elements.
int curVis = getSystemUiVisibility();
setNavVisibility((curVis&SYSTEM_UI_FLAG_LOW_PROFILE) != 0);
}
void setBaseSystemUiVisibility(int visibility) {
mBaseSystemUiVisibility = visibility;
}
void setNavVisibility(boolean visible) {
int newVis = mBaseSystemUiVisibility;
if (!visible) {
newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN;
}
final boolean changed = newVis == getSystemUiVisibility();
// Unschedule any pending event to hide navigation if we are
// changing the visibility, or making the UI visible.
if (changed || visible) {
Handler h = getHandler();
if (h != null) {
h.removeCallbacks(mNavHider);
}
}
// Set the new desired visibility.
setSystemUiVisibility(newVis);
mTitleView.setVisibility(visible ? VISIBLE : INVISIBLE);
mSeekView.setVisibility(visible ? VISIBLE : INVISIBLE);
}
}
This second code sample shows a typical implementation of a View in a video playing application. In this situation, while the video is playing the application would like to go into a complete full-screen mode, to use as much of the display as possible for the video. When in this state the user can not interact with the application; the system intercepts touching on the screen to pop the UI out of full screen mode. See fitSystemWindows(android.graphics.Rect) for a sample layout that goes with this code.
public static class Content extends ImageView implements
View.OnSystemUiVisibilityChangeListener, View.OnClickListener,
ActionBar.OnMenuVisibilityListener {
Activity mActivity;
TextView mTitleView;
Button mPlayButton;
SeekBar mSeekView;
boolean mAddedMenuListener;
boolean mMenusOpen;
boolean mPaused;
boolean mNavVisible;
int mLastSystemUiVis;
Runnable mNavHider = new Runnable() {
@Override public void run() {
setNavVisibility(false);
}
};
public Content(Context context, AttributeSet attrs) {
super(context, attrs);
setOnSystemUiVisibilityChangeListener(this);
setOnClickListener(this);
}
public void init(Activity activity, TextView title, Button playButton,
SeekBar seek) {
// This called by the containing activity to supply the surrounding
// state of the video player that it will interact with.
mActivity = activity;
mTitleView = title;
mPlayButton = playButton;
mSeekView = seek;
mPlayButton.setOnClickListener(this);
setPlayPaused(true);
}
@Override protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mActivity != null) {
mAddedMenuListener = true;
mActivity.getActionBar().addOnMenuVisibilityListener(this);
}
}
@Override protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (mAddedMenuListener) {
mActivity.getActionBar().removeOnMenuVisibilityListener(this);
}
}
@Override public void onSystemUiVisibilityChange(int visibility) {
// Detect when we go out of nav-hidden mode, to clear our state
// back to having the full UI chrome up. Only do this when
// the state is changing and nav is no longer hidden.
int diff = mLastSystemUiVis ^ visibility;
mLastSystemUiVis = visibility;
if ((diff&SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
&& (visibility&SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
setNavVisibility(true);
}
}
@Override protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
// When we become visible or invisible, play is paused.
setPlayPaused(true);
}
@Override public void onClick(View v) {
if (v == mPlayButton) {
// Clicking on the play/pause button toggles its state.
setPlayPaused(!mPaused);
} else {
// Clicking elsewhere makes the navigation visible.
setNavVisibility(true);
}
}
@Override public void onMenuVisibilityChanged(boolean isVisible) {
mMenusOpen = isVisible;
setNavVisibility(true);
}
void setPlayPaused(boolean paused) {
mPaused = paused;
mPlayButton.setText(paused ? R.string.play : R.string.pause);
setKeepScreenOn(!paused);
setNavVisibility(true);
}
void setNavVisibility(boolean visible) {
int newVis = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| SYSTEM_UI_FLAG_LAYOUT_STABLE;
if (!visible) {
newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN
| SYSTEM_UI_FLAG_HIDE_NAVIGATION;
}
// If we are now visible, schedule a timer for us to go invisible.
if (visible) {
Handler h = getHandler();
if (h != null) {
h.removeCallbacks(mNavHider);
if (!mMenusOpen && !mPaused) {
// If the menus are open or play is paused, we will not auto-hide.
h.postDelayed(mNavHider, 3000);
}
}
}
// Set the new desired visibility.
setSystemUiVisibility(newVis);
mTitleView.setVisibility(visible ? VISIBLE : INVISIBLE);
mPlayButton.setVisibility(visible ? VISIBLE : INVISIBLE);
mSeekView.setVisibility(visible ? VISIBLE : INVISIBLE);
}
}
|
Unit |
setTag(tag: Any!)
Sets the tag associated with this view. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure.
|
Unit |
setTag(key: Int, tag: Any!)
Sets a tag associated with this view and a key. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure. The specified key should be an id declared in the resources of the application to ensure it is unique (see the ID resource type). Keys identified as belonging to the Android framework or not associated with any package will cause an IllegalArgumentException to be thrown.
|
Unit |
setTextAlignment(textAlignment: Int)
Set the text alignment.
|
Unit |
setTextDirection(textDirection: Int)
Set the text direction.
|
Unit |
setTooltipText(tooltipText: CharSequence?)
Sets the tooltip text which will be displayed in a small popup next to the view.
The tooltip will be displayed:
- On long click, unless it is handled otherwise (by OnLongClickListener or a context menu).
- On hover, after a brief delay since the pointer has stopped moving
Note: Do not override this method, as it will have no effect on the text displayed in the tooltip.
|
Unit |
setTop(top: Int)
Sets the top position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setTouchDelegate(delegate: TouchDelegate!)
Sets the TouchDelegate for this View.
|
Unit |
setTransitionAlpha(alpha: Float)
This property is intended only for use by the Fade transition, which animates it to produce a visual translucency that does not side-effect (or get affected by) the real alpha property. This value is composited with the other alpha value (and the AlphaAnimation value, when that is present) to produce a final visual translucency result, which is what is passed into the DisplayList.
|
Unit |
setTransitionName(transitionName: String!)
Sets the name of the View to be used to identify Views in Transitions. Names should be unique in the View hierarchy.
|
Unit |
setTransitionVisibility(visibility: Int)
Changes the visibility of this View without triggering any other changes. This should only be used by animation frameworks, such as android.transition.Transition, where visibility changes should not adjust focus or trigger a new layout. Application developers should use setVisibility instead to ensure that the hierarchy is correctly updated.
Only call this method when a temporary visibility must be applied during an animation and the original visibility value is guaranteed to be reset after the animation completes. Use setVisibility in all other cases.
|
Unit |
setTranslationX(translationX: Float)
Sets the horizontal location of this view relative to its left position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
|
Unit |
setTranslationY(translationY: Float)
Sets the vertical location of this view relative to its top position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
|
Unit |
setTranslationZ(translationZ: Float)
Sets the depth location of this view relative to its elevation.
|
Unit |
setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled: Boolean)
Define whether the vertical edges should be faded when this view is scrolled vertically.
|
Unit |
setVerticalScrollBarEnabled(verticalScrollBarEnabled: Boolean)
Define whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Unit |
setVerticalScrollbarPosition(position: Int)
Set the position of the vertical scroll bar. Should be one of SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT or SCROLLBAR_POSITION_RIGHT.
|
Unit |
setVerticalScrollbarThumbDrawable(drawable: Drawable?)
Defines the vertical scrollbar thumb drawable
|
Unit |
setVerticalScrollbarTrackDrawable(drawable: Drawable?)
Defines the vertical scrollbar track drawable
|
Unit |
setVisibility(visibility: Int)
Set the visibility state of this view.
|
Unit |
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)
When a View's drawing cache is enabled, drawing is redirected to an offscreen bitmap. Some views, like an ImageView, must be able to bypass this mechanism if they already draw a single bitmap, to avoid unnecessary usage of the memory.
|
Unit |
setWillNotDraw(willNotDraw: Boolean)
If this view doesn't do any drawing on its own, set this flag to allow further optimizations. By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup. Typically, if you override onDraw(android.graphics.Canvas) you should clear this flag.
|
Unit |
setX(x: Float)
Sets the visual x position of this view, in pixels. This is equivalent to setting the translationX property to be the difference between the x value passed in and the current left property.
|
Unit |
setY(y: Float)
Sets the visual y position of this view, in pixels. This is equivalent to setting the translationY property to be the difference between the y value passed in and the current top property.
|
Unit |
setZ(z: Float)
Sets the visual z position of this view, in pixels. This is equivalent to setting the translationZ property to be the difference between the z value passed in and the current elevation property.
|
ActionMode! |
startActionMode(callback: ActionMode.Callback!)
Start an action mode with the default type ActionMode#TYPE_PRIMARY.
|
ActionMode! |
startActionMode(callback: ActionMode.Callback!, type: Int)
Start an action mode with the given type.
|
Unit |
startAnimation(animation: Animation!)
Start the specified animation now.
|
Boolean |
startDrag(data: ClipData!, shadowBuilder: View.DragShadowBuilder!, myLocalState: Any!, flags: Int)
|
Boolean |
startDragAndDrop(data: ClipData!, shadowBuilder: View.DragShadowBuilder!, myLocalState: Any!, flags: Int)
Starts a drag and drop operation. When your application calls this method, it passes a android.view.View.DragShadowBuilder object to the system. The system calls this object's DragShadowBuilder#onProvideShadowMetrics(Point, Point) to get metrics for the drag shadow, and then calls the object's DragShadowBuilder#onDrawShadow(Canvas) to draw the drag shadow itself.
Once the system has the drag shadow, it begins the drag and drop operation by sending drag events to all the View objects in your application that are currently visible. It does this either by calling the View object's drag listener (an implementation of onDrag() or by calling the View object's onDragEvent() method. Both are passed a android.view.DragEvent object that has a android.view.DragEvent#getAction() value of android.view.DragEvent#ACTION_DRAG_STARTED.
Your application can invoke startDragAndDrop() on any attached View object. The View object does not need to be the one used in android.view.View.DragShadowBuilder, nor does it need to be related to the View the user selected for dragging.
|
Boolean |
startNestedScroll(axes: Int)
Begin a nestable scroll operation along the given axes.
A view starting a nested scroll promises to abide by the following contract:
The view will call startNestedScroll upon initiating a scroll operation. In the case of a touch scroll this corresponds to the initial MotionEvent#ACTION_DOWN. In the case of touch scrolling the nested scroll will be terminated automatically in the same manner as ViewParent#requestDisallowInterceptTouchEvent(boolean). In the event of programmatic scrolling the caller must explicitly call stopNestedScroll() to indicate the end of the nested scroll.
If startNestedScroll returns true, a cooperative parent was found. If it returns false the caller may ignore the rest of this contract until the next scroll. Calling startNestedScroll while a nested scroll is already in progress will return true.
At each incremental step of the scroll the caller should invoke dispatchNestedPreScroll once it has calculated the requested scrolling delta. If it returns true the nested scrolling parent at least partially consumed the scroll and the caller should adjust the amount it scrolls by.
After applying the remainder of the scroll delta the caller should invoke dispatchNestedScroll, passing both the delta consumed and the delta unconsumed. A nested scrolling parent may treat these values differently. See ViewParent#onNestedScroll(View, int, int, int, int).
|
Unit |
stopNestedScroll()
Stop a nested scroll in progress.
Calling this method when a nested scroll is not currently in progress is harmless.
|
String |
toString()
|
Unit |
transformMatrixToGlobal(matrix: Matrix)
Modifies the input matrix such that it maps view-local coordinates to on-screen coordinates.
|
Unit |
transformMatrixToLocal(matrix: Matrix)
Modifies the input matrix such that it maps on-screen coordinates to view-local coordinates.
|
Unit |
unscheduleDrawable(who: Drawable, what: Runnable)
Cancels a scheduled action on a drawable.
|
Unit |
unscheduleDrawable(who: Drawable!)
Unschedule any events associated with the given Drawable. This can be used when selecting a new Drawable into a view, so that the previous one is completely unscheduled.
|
Unit |
updateDragShadow(shadowBuilder: View.DragShadowBuilder!)
Updates the drag shadow for the ongoing drag and drop operation.
|
Boolean |
willNotCacheDrawing()
Returns whether or not this View can cache its drawing or not.
|
Boolean |
willNotDraw()
Returns whether or not this View draws on its own.
|
|
Inherited properties
|
From class View
Property<View!, Float!>! |
ALPHA
A Property wrapper around the alpha functionality handled by the View#setAlpha(float) and View#getAlpha() methods.
|
IntArray! |
EMPTY_STATE_SET
Indicates the view has no states set. States are used with android.graphics.drawable.Drawable to change the drawing of the view depending on its state.
|
IntArray! |
ENABLED_FOCUSED_SELECTED_STATE_SET
Indicates the view is enabled, focused and selected.
|
IntArray! |
ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled, focused, selected and its window has the focus.
|
IntArray! |
ENABLED_FOCUSED_STATE_SET
Indicates the view is enabled and has the focus.
|
IntArray! |
ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled, focused and its window has the focus.
|
IntArray! |
ENABLED_SELECTED_STATE_SET
Indicates the view is enabled and selected.
|
IntArray! |
ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled, selected and its window has the focus.
|
IntArray! |
ENABLED_STATE_SET
Indicates the view is enabled. States are used with android.graphics.drawable.Drawable to change the drawing of the view depending on its state.
|
IntArray! |
ENABLED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled and that its window has focus.
|
IntArray! |
FOCUSED_SELECTED_STATE_SET
Indicates the view is focused and selected.
|
IntArray! |
FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is focused, selected and its window has the focus.
|
IntArray! |
FOCUSED_STATE_SET
Indicates the view is focused. States are used with android.graphics.drawable.Drawable to change the drawing of the view depending on its state.
|
IntArray! |
FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view has the focus and that its window has the focus.
|
IntArray! |
PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET
Indicates the view is pressed, enabled, focused and selected.
|
IntArray! |
PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled, focused, selected and its window has the focus.
|
IntArray! |
PRESSED_ENABLED_FOCUSED_STATE_SET
Indicates the view is pressed, enabled and focused.
|
IntArray! |
PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled, focused and its window has the focus.
|
IntArray! |
PRESSED_ENABLED_SELECTED_STATE_SET
Indicates the view is pressed, enabled and selected.
|
IntArray! |
PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled, selected and its window has the focus.
|
IntArray! |
PRESSED_ENABLED_STATE_SET
Indicates the view is pressed and enabled.
|
IntArray! |
PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled and its window has the focus.
|
IntArray! |
PRESSED_FOCUSED_SELECTED_STATE_SET
Indicates the view is pressed, focused and selected.
|
IntArray! |
PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, focused, selected and its window has the focus.
|
IntArray! |
PRESSED_FOCUSED_STATE_SET
Indicates the view is pressed and focused.
|
IntArray! |
PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, focused and its window has the focus.
|
IntArray! |
PRESSED_SELECTED_STATE_SET
Indicates the view is pressed and selected.
|
IntArray! |
PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, selected and its window has the focus.
|
IntArray! |
PRESSED_STATE_SET
Indicates the view is pressed. States are used with android.graphics.drawable.Drawable to change the drawing of the view depending on its state.
|
IntArray! |
PRESSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed and its window has the focus.
|
Property<View!, Float!>! |
ROTATION
A Property wrapper around the rotation functionality handled by the View#setRotation(float) and View#getRotation() methods.
|
Property<View!, Float!>! |
ROTATION_X
A Property wrapper around the rotationX functionality handled by the View#setRotationX(float) and View#getRotationX() methods.
|
Property<View!, Float!>! |
ROTATION_Y
A Property wrapper around the rotationY functionality handled by the View#setRotationY(float) and View#getRotationY() methods.
|
Property<View!, Float!>! |
SCALE_X
A Property wrapper around the scaleX functionality handled by the View#setScaleX(float) and View#getScaleX() methods.
|
Property<View!, Float!>! |
SCALE_Y
A Property wrapper around the scaleY functionality handled by the View#setScaleY(float) and View#getScaleY() methods.
|
IntArray! |
SELECTED_STATE_SET
Indicates the view is selected. States are used with android.graphics.drawable.Drawable to change the drawing of the view depending on its state.
|
IntArray! |
SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is selected and that its window has the focus.
|
Property<View!, Float!>! |
TRANSLATION_X
A Property wrapper around the translationX functionality handled by the View#setTranslationX(float) and View#getTranslationX() methods.
|
Property<View!, Float!>! |
TRANSLATION_Y
A Property wrapper around the translationY functionality handled by the View#setTranslationY(float) and View#getTranslationY() methods.
|
Property<View!, Float!>! |
TRANSLATION_Z
A Property wrapper around the translationZ functionality handled by the View#setTranslationZ(float) and View#getTranslationZ() methods.
|
IntArray! |
WINDOW_FOCUSED_STATE_SET
Indicates the view's window has focus. States are used with android.graphics.drawable.Drawable to change the drawing of the view depending on its state.
|
Property<View!, Float!>! |
X
A Property wrapper around the x functionality handled by the View#setX(float) and View#getX() methods.
|
Property<View!, Float!>! |
Y
A Property wrapper around the y functionality handled by the View#setY(float) and View#getY() methods.
|
Property<View!, Float!>! |
Z
A Property wrapper around the z functionality handled by the View#setZ(float) and View#getZ() methods.
|
|
XML attributes
android:allowUndo
android:allowUndo
Whether undo should be allowed for editable text. Defaults to true.
May be a boolean value, such as "true" or "false".
android:autoLink
android:autoLink
Controls whether links such as urls and email addresses are automatically found and converted to clickable links. The default value is "none", disabling this feature.
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| all |
f |
Match all patterns (equivalent to web|email|phone|map). |
| email |
2 |
Match email addresses. |
| map |
8 |
Match map addresses. Deprecated: see android.text.util.Linkify#MAP_ADDRESSES. |
| none |
0 |
Match no patterns (default). |
| phone |
4 |
Match phone numbers. |
| web |
1 |
Match Web URLs. |
android:autoSizeMaxTextSize
android:autoSizeMaxTextSize
The maximum text size constraint to be used when auto-sizing text.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:autoSizeMinTextSize
android:autoSizeMinTextSize
The minimum text size constraint to be used when auto-sizing text.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:autoSizePresetSizes
android:autoSizePresetSizes
Resource array of dimensions to be used in conjunction with
autoSizeTextType set to
uniform. Overrides
autoSizeStepGranularity if set.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
May be an integer value, such as "100".
May be a boolean value, such as "true" or "false".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
May be a floating point value, such as "1.2".
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.
android:autoSizeStepGranularity
android:autoSizeStepGranularity
Specify the auto-size step size if
autoSizeTextType is set to
uniform. The default is 1px. Overwrites
autoSizePresetSizes if set.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:autoSizeTextType
android:autoSizeTextType
Specify the type of auto-size. Note that this feature is not supported by EditText, works only for TextView.
Must be one of the following constant values.
| Constant |
Value |
Description |
| none |
0 |
No auto-sizing (default). |
| uniform |
1 |
Uniform horizontal and vertical text size scaling to fit within the container. |
android:autoText
android:autoText
If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. The default is "false". {@deprecated Use inputType instead.}
May be a boolean value, such as "true" or "false".
android:breakStrategy
android:breakStrategy
Break strategy (control over paragraph layout).
Must be one of the following constant values.
| Constant |
Value |
Description |
| balanced |
2 |
Line breaking strategy balances line lengths. |
| high_quality |
1 |
Line breaking uses high-quality strategy, including hyphenation. |
| simple |
0 |
Line breaking uses simple strategy. |
android:bufferType
android:bufferType
Determines the minimum type that getText() will return. The default is "normal". Note that EditText and LogTextBox always return Editable, even if you specify something less powerful here.
Must be one of the following constant values.
| Constant |
Value |
Description |
| editable |
2 |
Can only return Spannable and Editable. |
| normal |
0 |
Can return any CharSequence, possibly a Spanned one if the source text was Spanned. |
| spannable |
1 |
Can only return Spannable. |
android:capitalize
android:capitalize
If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. The default is "none". {@deprecated Use inputType instead.}
Must be one of the following constant values.
| Constant |
Value |
Description |
| characters |
3 |
Capitalize every character. |
| 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. |
android:cursorVisible
android:cursorVisible
Makes the cursor visible (the default) or invisible.
May be a boolean value, such as "true" or "false".
android:digits
android:digits
If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. If this is set, numeric is implied to be true. The default is false.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:drawableBottom
android:drawableBottom
The drawable to be drawn below the text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:drawableEnd
android:drawableEnd
The drawable to be drawn to the end of the text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:drawableLeft
android:drawableLeft
The drawable to be drawn to the left of the text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:drawablePadding
android:drawablePadding
The padding between the drawables and the text.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:drawableRight
android:drawableRight
The drawable to be drawn to the right of the text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:drawableStart
android:drawableStart
The drawable to be drawn to the start of the text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:drawableTint
android:drawableTint
Tint to apply to the compound (left, top, etc.) drawables.
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:drawableTintMode
android:drawableTintMode
Blending mode used to apply the compound (left, top, etc.) drawables tint.
Must be one of the following constant values.
| Constant |
Value |
Description |
| add |
10 |
Combines the tint and drawable color and alpha channels, clamping the result to valid color values. Saturate(S + D) |
| multiply |
e |
Multiplies the color and alpha channels of the drawable with those of the tint. [Sa * Da, Sc * Dc] |
| screen |
f |
[Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] |
| src_atop |
9 |
The tint is drawn above the drawable, but with the drawable’s alpha channel masking the result. [Da, Sc * Da + (1 - Sa) * Dc] |
| src_in |
5 |
The tint is masked by the alpha channel of the drawable. The drawable’s color channels are thrown out. [Sa * Da, Sc * Da] |
| src_over |
3 |
The tint is drawn on top of the drawable. [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] |
android:drawableTop
android:drawableTop
The drawable to be drawn above the text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:editable
android:editable
If set, specifies that this TextView has an input method. It will be a textual one unless it has otherwise been specified. For TextView, this is false by default. For EditText, it is true by default. {@deprecated Use inputType instead.}
May be a boolean value, such as "true" or "false".
android:editorExtras
android:editorExtras
Reference to an
<input-extras> XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. This simply fills in the
EditorInfo.extras field when the input method is connected.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
android:elegantTextHeight
android:elegantTextHeight
Elegant text height, especially for less compacted complex script text.
May be a boolean value, such as "true" or "false".
android:ellipsize
android:ellipsize
If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. You will often also want to set scrollHorizontally or singleLine as well so that the text as a whole is also constrained to a single line instead of still allowed to be broken onto multiple lines.
Must be one of the following constant values.
| Constant |
Value |
Description |
| end |
3 |
|
| marquee |
4 |
|
| middle |
2 |
|
| none |
0 |
|
| start |
1 |
|
android:ems
android:ems
Makes the TextView be exactly this many ems wide.
May be an integer value, such as "100".
android:enabled
android:enabled
Specifies whether the widget is enabled. The interpretation of the enabled state varies by subclass. For example, a non-enabled EditText prevents the user from editing the contained text, and a non-enabled Button prevents the user from tapping the button. The appearance of enabled and non-enabled widgets may differ, if the drawables referenced from evaluating state_enabled differ.
May be a boolean value, such as "true" or "false".
android:fallbackLineSpacing
android:fallbackLineSpacing
Whether to respect the ascent and descent of the fallback fonts that are used in displaying the text. When true, fallback fonts that end up getting used can increase the ascent and descent of the lines that they are used on.
May be a boolean value, such as "true" or "false".
android:fontFamily
android:fontFamily
Font family (named by string or as a font resource reference) for the text.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:fontFeatureSettings
android:fontFeatureSettings
Font feature settings.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:fontVariationSettings
android:fontVariationSettings
Font variation settings.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:freezesText
android:freezesText
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. By default this is disabled; it can be useful when the contents of a text view is not stored in a persistent place such as a content provider. For
android.widget.EditText it is always enabled, regardless of the value of the attribute.
May be a boolean value, such as "true" or "false".
android:gravity
android:gravity
Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view.
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| bottom |
50 |
Push object to the bottom of its container, not changing its size. |
| center |
11 |
Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |
| center_horizontal |
1 |
Place object in the horizontal center of its container, not changing its size. |
| center_vertical |
10 |
Place object in the vertical center of its container, not changing its size. |
| clip_horizontal |
8 |
Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges. |
| clip_vertical |
80 |
Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges. |
| end |
800005 |
Push object to the end of its container, not changing its size. |
| fill |
77 |
Grow the horizontal and vertical size of the object if needed so it completely fills its container. |
| fill_horizontal |
7 |
Grow the horizontal size of the object if needed so it completely fills its container. |
| fill_vertical |
70 |
Grow the vertical size of the object if needed so it completely fills its container. |
| left |
3 |
Push object to the left of its container, not changing its size. |
| right |
5 |
Push object to the right of its container, not changing its size. |
| start |
800003 |
Push object to the beginning of its container, not changing its size. |
| top |
30 |
Push object to the top of its container, not changing its size. |
android:height
android:height
Makes the TextView be exactly this tall. You could get the same effect by specifying this number in the layout parameters.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:hint
android:hint
Hint text to display when the text is empty.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:hyphenationFrequency
android:hyphenationFrequency
Frequency of automatic hyphenation.
Must be one of the following constant values.
| Constant |
Value |
Description |
| full |
2 |
Standard amount of hyphenation, useful for running text and for screens with limited space for text. |
| none |
0 |
No hyphenation. |
| normal |
1 |
Less frequent hyphenation, useful for informal use cases, such as chat messages. |
android:imeActionId
android:imeActionId
Supply a value for
EditorInfo.actionId used when an input method is connected to the text view.
May be an integer value, such as "100".
android:imeActionLabel
android:imeActionLabel
Supply a value for
EditorInfo.actionLabel used when an input method is connected to the text view.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:imeOptions
android:imeOptions
Additional features you can enable in an IME associated with an editor to improve the integration with your application. The constants here correspond to those defined by
android.view.inputmethod.EditorInfo#imeOptions.
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| actionDone |
6 |
The action key performs a "done" operation, closing the soft input method. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_DONE. |
| actionGo |
2 |
The action key performs a "go" operation to take the user to the target of the text they typed. Typically used, for example, when entering a URL. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_GO. |
| actionNext |
5 |
The action key performs a "next" operation, taking the user to the next field that will accept text. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_NEXT. |
| actionNone |
1 |
This editor has no action associated with it. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_NONE. |
| actionPrevious |
7 |
The action key performs a "previous" operation, taking the user to the previous field that will accept text. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_PREVIOUS. |
| actionSearch |
3 |
The action key performs a "search" operation, taking the user to the results of searching for the text the have typed (in whatever context is appropriate). Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_SEARCH. |
| actionSend |
4 |
The action key performs a "send" operation, delivering the text to its target. This is typically used when composing a message. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_SEND. |
| actionUnspecified |
0 |
There is no specific action associated with this editor, let the editor come up with its own if it can. Corresponds to android.view.inputmethod.EditorInfo#IME_NULL. |
| flagForceAscii |
80000000 |
Used to request that the IME should be capable of inputting ASCII characters. The intention of this flag is to ensure that the user can type Roman alphabet characters in a android.widget.TextView used for, typically, account ID or password input. It is expected that IMEs normally are able to input ASCII even without being told so (such IMEs already respect this flag in a sense), but there could be some cases they aren't when, for instance, only non-ASCII input languages like Arabic, Greek, Hebrew, Russian are enabled in the IME. Applications need to be aware that the flag is not a guarantee, and not all IMEs will respect it. However, it is strongly recommended for IME authors to respect this flag especially when their IME could end up with a state that has only non-ASCII input languages enabled.
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_FORCE_ASCII.
|
| flagNavigateNext |
8000000 |
Used to specify that there is something interesting that a forward navigation can focus on. This is like using actionNext, except allows the IME to be multiline (with an enter key) as well as provide forward navigation. Note that some IMEs may not be able to do this, especially when running on a small screen where there is little space. In that case it does not need to present a UI for this option. Like actionNext, if the user selects the IME's facility to forward navigate, this will show up in the application at InputConnection.performEditorAction(int).
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NAVIGATE_NEXT.
|
| flagNavigatePrevious |
4000000 |
Like flagNavigateNext, but specifies there is something interesting that a backward navigation can focus on. If the user selects the IME's facility to backward navigate, this will show up in the application as an actionPrevious at InputConnection.performEditorAction(int).
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NAVIGATE_PREVIOUS.
|
| flagNoAccessoryAction |
20000000 |
Used in conjunction with a custom action, this indicates that the action should not be available as an accessory button when the input method is full-screen. Note that by setting this flag, there can be cases where the action is simply never available to the user. Setting this generally means that you think showing text being edited is more important than the action you have supplied.
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_ACCESSORY_ACTION.
|
| flagNoEnterAction |
40000000 |
Used in conjunction with a custom action, this indicates that the action should not be available in-line as a replacement for the "enter" key. Typically this is because the action has such a significant impact or is not recoverable enough that accidentally hitting it should be avoided, such as sending a message. Note that android.widget.TextView will automatically set this flag for you on multi-line text views.
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION.
|
| flagNoExtractUi |
10000000 |
Used to specify that the IME does not need to show its extracted text UI. For input methods that may be fullscreen, often when in landscape mode, this allows them to be smaller and let part of the application be shown behind. Though there will likely be limited access to the application available from the user, it can make the experience of a (mostly) fullscreen IME less jarring. Note that when this flag is specified the IME may not be set up to be able to display text, so it should only be used in situations where this is not needed.
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_EXTRACT_UI.
|
| flagNoFullscreen |
2000000 |
Used to request that the IME never go into fullscreen mode. Applications need to be aware that the flag is not a guarantee, and not all IMEs will respect it.
Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_FULLSCREEN.
|
| flagNoPersonalizedLearning |
1000000 |
Used to request that the IME should not update any personalized data such as typing history and personalized language model based on what the user typed on this text editing object. Typical use cases are:
- When the application is in a special mode, where user's activities are expected to be not recorded in the application's history. Some web browsers and chat applications may have this kind of modes.
- When storing typing history does not make much sense. Specifying this flag in typing games may help to avoid typing history from being filled up with words that the user is less likely to type in their daily life. Another example is that when the application already knows that the expected input is not a valid word (e.g. a promotion code that is not a valid word in any natural language).
Applications need to be aware that the flag is not a guarantee, and some IMEs may not respect it.
|
| normal |
0 |
There are no special semantics associated with this editor. |
android:includeFontPadding
android:includeFontPadding
Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. (Normally true).
May be a boolean value, such as "true" or "false".
android:inputMethod
android:inputMethod
If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). {@deprecated Use inputType instead.}
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:inputType
android:inputType
The type of data being placed in a text field, used to help an input method decide how to let the user enter text. The constants here correspond to those defined by
android.text.InputType. Generally you can select a single value, though some can be combined together as indicated. Setting this attribute to anything besides none also implies that the text is editable.
Must be one or more (separated by '|') of the following constant values.
android:justificationMode
android:justificationMode
Mode for justification.
Must be one of the following constant values.
| Constant |
Value |
Description |
| inter_word |
1 |
Justification by stretching word spacing. |
| none |
0 |
No justification. |
android:letterSpacing
android:letterSpacing
Text letter-spacing.
May be a floating point value, such as "1.2".
android:lineSpacingExtra
android:lineSpacingExtra
Extra spacing between lines of text. The value will not be applied for the last line of text.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:lineSpacingMultiplier
android:lineSpacingMultiplier
Extra spacing between lines of text, as a multiplier. The value will not be applied for the last line of text.
May be a floating point value, such as "1.2".
android:lines
android:lines
Makes the TextView be exactly this many lines tall.
May be an integer value, such as "100".
android:linksClickable
android:linksClickable
If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found.
May be a boolean value, such as "true" or "false".
android:marqueeRepeatLimit
android:marqueeRepeatLimit
The number of times to repeat the marquee animation. Only applied if the TextView has marquee enabled.
May be an integer value, such as "100".
Must be one of the following constant values.
| Constant |
Value |
Description |
| marquee_forever |
ffffffff |
Indicates that marquee should repeat indefinitely. |
android:maxEms
android:maxEms
Makes the TextView be at most this many ems wide.
May be an integer value, such as "100".
android:maxHeight
android:maxHeight
Makes the TextView be at most this many pixels tall.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:maxLength
android:maxLength
Set an input filter to constrain the text length to the specified number.
May be an integer value, such as "100".
android:maxLines
android:maxLines
Makes the TextView be at most this many lines tall. When used on an editable text, the
inputType attribute's value must be combined with the
textMultiLine flag for the maxLines attribute to apply.
May be an integer value, such as "100".
android:maxWidth
android:maxWidth
Makes the TextView be at most this many pixels wide.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:minEms
android:minEms
Makes the TextView be at least this many ems wide.
May be an integer value, such as "100".
android:minHeight
android:minHeight
Makes the TextView be at least this many pixels tall.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:minLines
android:minLines
Makes the TextView be at least this many lines tall. When used on an editable text, the
inputType attribute's value must be combined with the
textMultiLine flag for the minLines attribute to apply.
May be an integer value, such as "100".
android:minWidth
android:minWidth
Makes the TextView be at least this many pixels wide.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:numeric
android:numeric
If set, specifies that this TextView has a numeric input method. The default is false. {@deprecated Use inputType instead.}
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| decimal |
5 |
Input is numeric, with decimals allowed. |
| integer |
1 |
Input is numeric. |
| signed |
3 |
Input is numeric, with sign allowed. |
android:password
android:password
Whether the characters of the field are displayed as password dots instead of themselves. {@deprecated Use inputType instead.}
May be a boolean value, such as "true" or "false".
android:phoneNumber
android:phoneNumber
If set, specifies that this TextView has a phone number input method. The default is false. {@deprecated Use inputType instead.}
May be a boolean value, such as "true" or "false".
android:privateImeOptions
android:privateImeOptions
An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. This simply fills in the
EditorInfo.privateImeOptions field when the input method is connected.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:scrollHorizontally
android:scrollHorizontally
Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally).
May be a boolean value, such as "true" or "false".
android:selectAllOnFocus
android:selectAllOnFocus
If the text is selectable, select it all when the view takes focus.
May be a boolean value, such as "true" or "false".
android:shadowColor
android:shadowColor
Place a blurred shadow of text underneath the text, drawn with the specified color. The text shadow produced does not interact with properties on View that are responsible for real time shadows,
elevation and
translationZ.
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:shadowDx
android:shadowDx
Horizontal offset of the text shadow.
May be a floating point value, such as "1.2".
android:shadowDy
android:shadowDy
Vertical offset of the text shadow.
May be a floating point value, such as "1.2".
android:shadowRadius
android:shadowRadius
Blur radius of the text shadow.
May be a floating point value, such as "1.2".
android:singleLine
android:singleLine
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. The default value is false (multi-line wrapped text mode) for non-editable text, but if you specify any value for inputType, the default is true (single-line input field mode). {@deprecated This attribute is deprecated. Use
maxLines instead to change * the layout of a static text, and use the
textMultiLine flag in the * inputType attribute instead for editable text views (if both singleLine and inputType * are supplied, the inputType flags will override the value of singleLine). }
May be a boolean value, such as "true" or "false".
android:text
android:text
Text to display.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:textAppearance
android:textAppearance
Base text color, typeface, size, and style.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
android:textColor
android:textColor
Text color.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:textColorHighlight
android:textColorHighlight
Color of the text selection highlight.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:textColorHint
android:textColorHint
Color of the hint text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:textColorLink
android:textColorLink
Text color for links.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".
android:textCursorDrawable
android:textCursorDrawable
Reference to a drawable that will be drawn under the insertion cursor.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
android:textFontWeight
android:textFontWeight
Weight for the font used in the TextView.
May be an integer value, such as "100".
android:textScaleX
android:textScaleX
Sets the horizontal scaling factor for the text.
May be a floating point value, such as "1.2".
android:textSelectHandle
android:textSelectHandle
Reference to a drawable that will be used to display a text selection anchor for positioning the cursor within text.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
android:textSelectHandleLeft
android:textSelectHandleLeft
Reference to a drawable that will be used to display a text selection anchor on the left side of a selection region.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
android:textSelectHandleRight
android:textSelectHandleRight
Reference to a drawable that will be used to display a text selection anchor on the right side of a selection region.
May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
android:textSize
android:textSize
Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp).
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
android:textStyle
android:textStyle
Style (normal, bold, italic, bold|italic) for the text.
Must be one or more (separated by '|') of the following constant values.
| Constant |
Value |
Description |
| bold |
1 |
|
| italic |
2 |
|
| normal |
0 |
|
android:typeface
android:typeface
Typeface (normal, sans, serif, monospace) for the text.
Must be one of the following constant values.
| Constant |
Value |
Description |
| monospace |
3 |
|
| normal |
0 |
|
| sans |
1 |
|
| serif |
2 |
|
android:width
android:width
Makes the TextView be exactly this wide. You could get the same effect by specifying this number in the layout parameters.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).
Constants
AUTO_SIZE_TEXT_TYPE_NONE
static val AUTO_SIZE_TEXT_TYPE_NONE: Int
The TextView does not auto-size text (default).
Value: 0
AUTO_SIZE_TEXT_TYPE_UNIFORM
static val AUTO_SIZE_TEXT_TYPE_UNIFORM: Int
The TextView scales text size both horizontally and vertically to fit within the container.
Value: 1
Public constructors
Public methods
addExtraDataToAccessibilityNodeInfo
open fun addExtraDataToAccessibilityNodeInfo(info: AccessibilityNodeInfo, extraDataKey: String, arguments: Bundle?): Unit
| Parameters |
info |
AccessibilityNodeInfo: The info to which to add the extra data. Never null. This value must never be null. |
extraDataKey |
String: A key specifying the type of extra data to add to the info. The extra data should be added to the Bundle returned by the info's AccessibilityNodeInfo#getExtras method. Never null. This value must never be null. |
arguments |
Bundle?: A Bundle holding any arguments relevant for this request. May be null if the service provided no arguments. This value may be null. |
addTextChangedListener
open fun addTextChangedListener(watcher: TextWatcher!): Unit
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.
In 1.0, the TextWatcher#afterTextChanged method was erroneously not called after setText calls. Now, doing setText if there are any text changed listeners forces the buffer type to Editable if it would not otherwise be and does call this method.
append
open fun append(text: CharSequence!, start: Int, end: Int): Unit
Convenience method to append the specified text slice to the TextView's display buffer, upgrading it to android.widget.TextView.BufferType#EDITABLE if it was not already editable.
| Parameters |
text |
CharSequence!: text to be appended to the already displayed text |
start |
Int: the index of the first character in the text |
end |
Int: the index of the character following the last character in the text |
beginBatchEdit
open fun beginBatchEdit(): Unit
bringPointIntoView
open fun bringPointIntoView(offset: Int): Boolean
Move the point, specified by the offset, into the view if it is needed. This has to be called after layout. Returns true if anything changed.
cancelLongPress
open fun cancelLongPress(): Unit
computeScroll
open fun computeScroll(): Unit
debug
open fun debug(depth: Int): Unit
didTouchFocusSelect
open fun didTouchFocusSelect(): Boolean
Returns true, only while processing a touch gesture, if the initial touch down event caused focus to move to the text view and as a result its selection changed. Only valid while processing the touch gesture of interest, in an editable text view.
drawableHotspotChanged
open fun drawableHotspotChanged(x: Float, y: Float): Unit
| Parameters |
x |
Float: hotspot x coordinate |
y |
Float: hotspot y coordinate |
endBatchEdit
open fun endBatchEdit(): Unit
extractText
open fun extractText(request: ExtractedTextRequest!, outText: ExtractedText!): Boolean
If this TextView contains editable content, extract a portion of it based on the information in request in to outText.
| Return |
| Boolean: Returns true if the text was successfully extracted, else false. |
getAccessibilityClassName
open fun getAccessibilityClassName(): CharSequence!
getAutoLinkMask
fun getAutoLinkMask(): Int
Gets the autolink mask of the text. See Linkify#ALL and peers for possible values.
getAutoSizeMaxTextSize
open fun getAutoSizeMaxTextSize(): Int
| Return |
Int: the current auto-size maximum text size in pixels (the default is 112sp). Note that if auto-size has not been configured this function returns -1. |
getAutoSizeMinTextSize
open fun getAutoSizeMinTextSize(): Int
| Return |
Int: the current auto-size minimum text size in pixels (the default is 12sp). Note that if auto-size has not been configured this function returns -1. |
getAutoSizeStepGranularity
open fun getAutoSizeStepGranularity(): Int
| Return |
| Int: the current auto-size step granularity in pixels. |
getAutoSizeTextAvailableSizes
open fun getAutoSizeTextAvailableSizes(): IntArray!
| Return |
IntArray!: the current auto-size int sizes array (in pixels). |
getAutoSizeTextType
open fun getAutoSizeTextType(): Int
Returns the type of auto-size set for this widget.
getAutofillValue
open fun getAutofillValue(): AutofillValue?
Gets the TextView's current text for AutoFill. The value is trimmed to 100K chars if longer.
| Return |
AutofillValue?: current text, null if the text is not editable |
getBaseline
open fun getBaseline(): Int
| Return |
| Int: the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported |
getBreakStrategy
open fun getBreakStrategy(): Int
Gets the current strategy for breaking paragraphs into lines.
getCompoundDrawablePadding
open fun getCompoundDrawablePadding(): Int
Returns the padding between the compound drawables and the text.
getCompoundDrawableTintBlendMode
open fun getCompoundDrawableTintBlendMode(): BlendMode?
Returns the blending mode used to apply the tint to the compound drawables, if specified.
| Return |
BlendMode?: the blending mode used to apply the tint to the compound drawables This value may be null. |
getCompoundDrawableTintList
open fun getCompoundDrawableTintList(): ColorStateList!
getCompoundDrawableTintMode
open fun getCompoundDrawableTintMode(): PorterDuff.Mode!
Returns the blending mode used to apply the tint to the compound drawables, if specified.
| Return |
| PorterDuff.Mode!: the blending mode used to apply the tint to the compound drawables |
getCompoundDrawables
open fun getCompoundDrawables(): Array<Drawable!>
Returns drawables for the left, top, right, and bottom borders.
getCompoundDrawablesRelative
open fun getCompoundDrawablesRelative(): Array<Drawable!>
Returns drawables for the start, top, end, and bottom borders.
getCompoundPaddingBottom
open fun getCompoundPaddingBottom(): Int
Returns the bottom padding of the view, plus space for the bottom Drawable if any.
getCompoundPaddingEnd
open fun getCompoundPaddingEnd(): Int
Returns the end padding of the view, plus space for the end Drawable if any.
getCompoundPaddingLeft
open fun getCompoundPaddingLeft(): Int
Returns the left padding of the view, plus space for the left Drawable if any.
getCompoundPaddingRight
open fun getCompoundPaddingRight(): Int
Returns the right padding of the view, plus space for the right Drawable if any.
getCompoundPaddingStart
open fun getCompoundPaddingStart(): Int
Returns the start padding of the view, plus space for the start Drawable if any.
getCompoundPaddingTop
open fun getCompoundPaddingTop(): Int
Returns the top padding of the view, plus space for the top Drawable if any.
getCurrentHintTextColor
fun getCurrentHintTextColor(): Int
Return the current color selected to paint the hint text.
| Return |
| Int: Returns the current hint text color. |
getCurrentTextColor
fun getCurrentTextColor(): Int
Return the current color selected for normal text.
| Return |
| Int: Returns the current text color. |
getEditableText
open fun getEditableText(): Editable!
Return the text that TextView is displaying as an Editable object. If the text is not editable, null is returned.
getEllipsize
open fun getEllipsize(): TextUtils.TruncateAt!
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.
getError
open fun getError(): CharSequence!
Returns the error message that was set to be displayed with setError, or null if no error was set or if it the error was cleared by the widget after user input.
getExtendedPaddingBottom
open fun getExtendedPaddingBottom(): Int
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. It is only valid to call this after measuring.
getExtendedPaddingTop
open fun getExtendedPaddingTop(): Int
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. It is only valid to call this after measuring.
getFilters
open fun getFilters(): Array<InputFilter!>!
Returns the current list of input filters.
getFirstBaselineToTopHeight
open fun getFirstBaselineToTopHeight(): Int
Returns the distance between the first text baseline and the top of this TextView.
getFocusedRect
open fun getFocusedRect(r: Rect!): Unit
| Parameters |
r |
Rect!: The rectangle to fill in, in this view's coordinates. |
getFontVariationSettings
open fun getFontVariationSettings(): String?
Returns the font variation settings.
| Return |
| String?: the currently set font variation settings. Returns null if no variation is specified. |
getFreezesText
open fun getFreezesText(): Boolean
Return whether this text view is including its entire text contents in frozen icicles. For android.widget.EditText it always returns true.
| Return |
| Boolean: Returns true if text is included, false if it isn't. |
getGravity
open fun getGravity(): Int
Returns the horizontal and vertical alignment of this TextView.
getHighlightColor
open fun getHighlightColor(): Int
| Return |
| Int: the color used to display the selection highlight |
getHint
open fun getHint(): CharSequence!
Returns the hint that is displayed when the text of the TextView is empty.
getHintTextColors
fun getHintTextColors(): ColorStateList!
| Return |
| ColorStateList!: the color of the hint text, for the different states of this TextView. |
getHyphenationFrequency
open fun getHyphenationFrequency(): Int
Gets the current frequency of automatic hyphenation to be used when determining word breaks.
getImeActionId
open fun getImeActionId(): Int
Get the IME action ID previous set with setImeActionLabel.
getImeHintLocales
open fun getImeHintLocales(): LocaleList?
| Return |
LocaleList?: The current languages list "hint". null when no "hint" is available. |
getImeOptions
open fun getImeOptions(): Int
Get the type of the Input Method Editor (IME).
| Return |
| Int: the type of the IME |
getIncludeFontPadding
open fun getIncludeFontPadding(): Boolean
Gets whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.
getInputExtras
open fun getInputExtras(create: Boolean): Bundle!
Retrieve the input extras currently associated with the text view, which can be viewed as well as modified.
| Parameters |
create |
Boolean: If true, the extras will be created if they don't already exist. Otherwise, null will be returned if none have been created. |
getInputType
open fun getInputType(): Int
Get the type of the editable content.
getJustificationMode
open fun getJustificationMode(): Int
getKeyListener
fun getKeyListener(): KeyListener!
Gets the current KeyListener for the TextView. This will frequently be null for non-EditText TextViews.
| Return |
| KeyListener!: the current key listener for this TextView. |
getLastBaselineToBottomHeight
open fun getLastBaselineToBottomHeight(): Int
Returns the distance between the last text baseline and the bottom of this TextView.
getLayout
fun getLayout(): Layout!
Gets the android.text.Layout that is currently being used to display the text. This value can be null if the text or width has recently changed.
| Return |
| Layout!: The Layout that is currently being used to display the text. |
getLetterSpacing
open fun getLetterSpacing(): Float
Gets the text letter-space value, which determines the spacing between characters. The value returned is in ems. Normally, this value is 0.0.
| Return |
| Float: The text letter-space value in ems. |
getLineBounds
open fun getLineBounds(line: Int, bounds: Rect!): Int
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. If the internal Layout has not been built, return 0 and set bounds to (0, 0, 0, 0)
| Parameters |
line |
Int: which line to examine (0..getLineCount() - 1) |
bounds |
Rect!: Optional. If not null, it returns the extent of the line |
| Return |
| Int: the Y-coordinate of the baseline |
getLineCount
open fun getLineCount(): Int
Return the number of lines of text, or 0 if the internal Layout has not been built.
getLineHeight
open fun getLineHeight(): Int
Gets the vertical distance between lines of text, in pixels. Note that markup within the text can cause individual lines to be taller or shorter than this height, and the layout may contain additional first-or last-line padding.
| Return |
| Int: The height of one standard line in pixels. |
getLineSpacingExtra
open fun getLineSpacingExtra(): Float
Gets the line spacing extra space
| Return |
| Float: the extra space that is added to the height of each lines of this TextView. |
getLineSpacingMultiplier
open fun getLineSpacingMultiplier(): Float
Gets the line spacing multiplier
| Return |
| Float: the value by which each line's height is multiplied to get its actual height. |
getLinkTextColors
fun getLinkTextColors(): ColorStateList!
| Return |
| ColorStateList!: the list of colors used to paint the links in the text, for the different states of this TextView |
getMarqueeRepeatLimit
open fun getMarqueeRepeatLimit(): Int
Gets the number of times the marquee animation is repeated. Only meaningful if the TextView has marquee enabled.
| Return |
| Int: the number of times the marquee animation is repeated. -1 if the animation repeats indefinitely |
getMaxEms
open fun getMaxEms(): Int
Returns the maximum width of TextView in terms of ems or -1 if the maximum width was set using setMaxWidth(int) or setWidth(int).
| Return |
| Int: the maximum width of TextView in terms of ems or -1 if the maximum width is not defined in ems |
getMaxHeight
open fun getMaxHeight(): Int
Returns the maximum height of TextView in terms of pixels or -1 if the maximum height was set using setMaxLines(int) or setLines(int).
| Return |
| Int: the maximum height of TextView in terms of pixels or -1 if the maximum height is not defined in pixels |
getMaxLines
open fun getMaxLines(): Int
Returns the maximum height of TextView in terms of number of lines or -1 if the maximum height was set using setMaxHeight(int) or setHeight(int).
| Return |
| Int: the maximum height of TextView in terms of number of lines. -1 if the maximum height is not defined in lines. |
getMaxWidth
open fun getMaxWidth(): Int
Returns the maximum width of TextView in terms of pixels or -1 if the maximum width was set using setMaxEms(int) or setEms(int).
| Return |
| Int: the maximum width of TextView in terms of pixels. -1 if the maximum width is not defined in pixels |
getMinEms
open fun getMinEms(): Int
Returns the minimum width of TextView in terms of ems or -1 if the minimum width was set using setMinWidth(int) or setWidth(int).
| Return |
| Int: the minimum width of TextView in terms of ems. -1 if the minimum width is not defined in ems |
getMinHeight
open fun getMinHeight(): Int
Returns the minimum height of TextView in terms of pixels or -1 if the minimum height was set using setMinLines(int) or setLines(int).
| Return |
| Int: the minimum height of TextView in terms of pixels or -1 if the minimum height is not defined in pixels |
getMinLines
open fun getMinLines(): Int
Returns the minimum height of TextView in terms of number of lines or -1 if the minimum height was set using setMinHeight(int) or setHeight(int).
| Return |
| Int: the minimum height of TextView in terms of number of lines or -1 if the minimum height is not defined in lines |
getMinWidth
open fun getMinWidth(): Int
Returns the minimum width of TextView in terms of pixels or -1 if the minimum width was set using setMinEms(int) or setEms(int).
| Return |
| Int: the minimum width of TextView in terms of pixels or -1 if the minimum width is not defined in pixels |
getMovementMethod
fun getMovementMethod(): MovementMethod!
Gets the android.text.method.MovementMethod being used for this TextView, which provides positioning, scrolling, and text selection functionality. This will frequently be null for non-EditText TextViews.
| Return |
| MovementMethod!: the movement method being used for this TextView. |
getOffsetForPosition
open fun getOffsetForPosition(x: Float, y: Float): Int
Get the character offset closest to the specified absolute position. A typical use case is to pass the result of MotionEvent#getX() and MotionEvent#getY() to this method.
| Parameters |
x |
Float: The horizontal absolute position of a point on screen |
y |
Float: The vertical absolute position of a point on screen |
| Return |
| Int: the character offset for the character whose position is closest to the specified position. Returns -1 if there is no layout. |
getPaint
open fun getPaint(): TextPaint!
Gets the TextPaint used for the text. Use this only to consult the Paint's properties and not to change them.
| Return |
| TextPaint!: The base paint used for the text. |
getPaintFlags
open fun getPaintFlags(): Int
Gets the flags on the Paint being used to display the text.
| Return |
| Int: The flags on the Paint being used to display the text. |
getPrivateImeOptions
open fun getPrivateImeOptions(): String!
Get the private type of the content.
getShadowColor
open fun getShadowColor(): Int
Gets the color of the shadow layer.
| Return |
| Int: the color of the shadow layer |
getShadowDx
open fun getShadowDx(): Float
| Return |
| Float: the horizontal offset of the shadow layer |
getShadowDy
open fun getShadowDy(): Float
Gets the vertical offset of the shadow layer.
| Return |
| Float: The vertical offset of the shadow layer. |
getShadowRadius
open fun getShadowRadius(): Float
Gets the radius of the shadow layer.
| Return |
| Float: the radius of the shadow layer. If 0, the shadow layer is not visible |
getShowSoftInputOnFocus
fun getShowSoftInputOnFocus(): Boolean
Returns whether the soft input method will be made visible when this TextView gets focused. The default is true.
getTextColors
fun getTextColors(): ColorStateList!
Gets the text colors for the different states (normal, selected, focused) of the TextView.
getTextCursorDrawable
open fun getTextCursorDrawable(): Drawable?
Returns the Drawable corresponding to the text cursor. Note that any change applied to the cursor Drawable will not be visible until the cursor is hidden and then drawn again.
| Return |
Drawable?: the text cursor drawable This value may be null. |
getTextLocale
open fun getTextLocale(): Locale
Get the default primary Locale of the text in this TextView. This will always be the first member of getTextLocales().
| Return |
Locale: the default primary Locale of the text in this TextView. This value will never be null. |
getTextLocales
open fun getTextLocales(): LocaleList
Get the default LocaleList of the text in this TextView.
| Return |
LocaleList: the default LocaleList of the text in this TextView. This value will never be null. |
getTextScaleX
open fun getTextScaleX(): Float
Gets the extent by which text should be stretched horizontally. This will usually be 1.0.
| Return |
| Float: The horizontal scale factor. |
getTextSelectHandle
open fun getTextSelectHandle(): Drawable?
Returns the Drawable corresponding to the selection handle used for positioning the cursor within text. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
| Return |
Drawable?: the text select handle drawable This value may be null. |
getTextSelectHandleLeft
open fun getTextSelectHandleLeft(): Drawable?
Returns the Drawable corresponding to the left handle used for selecting text. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
| Return |
Drawable?: the left text selection handle drawable This value may be null. |
getTextSelectHandleRight
open fun getTextSelectHandleRight(): Drawable?
Returns the Drawable corresponding to the right handle used for selecting text. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
| Return |
Drawable?: the right text selection handle drawable This value may be null. |
getTextSize
open fun getTextSize(): Float
| Return |
| Float: the size (in pixels) of the default text size in this TextView. |
getTotalPaddingBottom
open fun getTotalPaddingBottom(): Int
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.
getTotalPaddingEnd
open fun getTotalPaddingEnd(): Int
Returns the total end padding of the view, including the end Drawable if any.
getTotalPaddingLeft
open fun getTotalPaddingLeft(): Int
Returns the total left padding of the view, including the left Drawable if any.
getTotalPaddingRight
open fun getTotalPaddingRight(): Int
Returns the total right padding of the view, including the right Drawable if any.
getTotalPaddingStart
open fun getTotalPaddingStart(): Int
Returns the total start padding of the view, including the start Drawable if any.
getTotalPaddingTop
open fun getTotalPaddingTop(): Int
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.
getTypeface
open fun getTypeface(): Typeface!
Gets the current Typeface that is used to style the text.
hasOverlappingRendering
open fun hasOverlappingRendering(): Boolean
| Return |
| Boolean: true if the content in this view might overlap, false otherwise. |
hasSelection
open fun hasSelection(): Boolean
Return true iff there is a selection of nonzero length inside this text view.
invalidateDrawable
open fun invalidateDrawable(drawable: Drawable): Unit
Invalidates the specified Drawable.
| Parameters |
who |
The drawable that is requesting the update. This value must never be null. |
drawable |
Drawable: This value must never be null. |
isAllCaps
open fun isAllCaps(): Boolean
Checks whether the transformation method applied to this TextView is set to ALL CAPS.
| Return |
| Boolean: Whether the current transformation method is for ALL CAPS. |
isCursorVisible
open fun isCursorVisible(): Boolean
| Return |
| Boolean: whether or not the cursor is visible (assuming this TextView is editable) |
isElegantTextHeight
open fun isElegantTextHeight(): Boolean
Get the value of the TextView's elegant height metrics flag. This setting selects font variants that have not been compacted to fit Latin-based vertical metrics, and also increases top and bottom bounds to provide more space.
| Return |
Boolean: true if the elegant height metrics flag is set. |
isFallbackLineSpacing
open fun isFallbackLineSpacing(): Boolean
| Return |
Boolean: whether fallback line spacing is enabled, true by default |
isHorizontallyScrollable
fun isHorizontallyScrollable(): Boolean
Returns whether the text is allowed to be wider than the View. If false, the text will be wrapped to the width of the View.
isInputMethodTarget
open fun isInputMethodTarget(): Boolean
Returns whether this text view is a current input method target. The default implementation just checks with InputMethodManager.
| Return |
| Boolean: True if the TextView is a current input method target; false otherwise. |
isSingleLine
open fun isSingleLine(): Boolean
Returns if the text is constrained to a single horizontally scrolling line ignoring new line characters instead of letting it wrap onto multiple lines.
isTextSelectable
open fun isTextSelectable(): Boolean
Returns the state of the textIsSelectable flag (See setTextIsSelectable()). Although you have to set this flag to allow users to select and copy text in a non-editable TextView, the content of an EditText can always be selected, independently of the value of this flag.
| Return |
| Boolean: True if the text displayed in this TextView can be selected by the user. |
jumpDrawablesToCurrentState
open fun jumpDrawablesToCurrentState(): Unit
length
open fun length(): Int
Returns the length, in characters, of the text managed by this TextView
| Return |
| Int: The length of the text managed by the TextView in characters. |
moveCursorToVisibleOffset
open fun moveCursorToVisibleOffset(): Boolean
Move the cursor, if needed, so that it is at an offset that is visible to the user. This will not move the cursor if it represents more than one character (a selection range). This will only work if the TextView contains spannable text; otherwise it will do nothing.
| Return |
| Boolean: True if the cursor was actually moved, false otherwise. |
onBeginBatchEdit
open fun onBeginBatchEdit(): Unit
Called by the framework in response to a request to begin a batch of edit operations through a call to link beginBatchEdit().
onCheckIsTextEditor
open fun onCheckIsTextEditor(): Boolean
| Return |
| Boolean: Returns true if this view is a text editor, else false. |
onCommitCompletion
open fun onCommitCompletion(text: CompletionInfo!): Unit
Called by the framework in response to a text completion from the current input method, provided by it calling InputConnection#commitCompletion. The default implementation does nothing; text views that are supporting auto-completion should override this to do their desired behavior.
| Parameters |
text |
CompletionInfo!: The auto complete text the user has selected. |
onCommitCorrection
open fun onCommitCorrection(info: CorrectionInfo!): Unit
Called by the framework in response to a text auto-correction (such as fixing a typo using a dictionary) from the current input method, provided by it calling InputConnection#commitCorrection(CorrectionInfo). The default implementation flashes the background of the corrected word to provide feedback to the user.
| Parameters |
info |
CorrectionInfo!: The auto correct info about the text that was corrected. |
onCreateInputConnection
open fun onCreateInputConnection(outAttrs: EditorInfo!): InputConnection!
| Parameters |
outAttrs |
EditorInfo!: Fill in with attribute information about the connection. |
onEndBatchEdit
open fun onEndBatchEdit(): Unit
Called by the framework in response to a request to end a batch of edit operations through a call to link endBatchEdit.
onGenericMotionEvent
open fun onGenericMotionEvent(event: MotionEvent!): Boolean
| Parameters |
event |
MotionEvent!: The generic motion event being processed. |
| Return |
| Boolean: True if the event was handled, false otherwise. |
onKeyDown
open fun onKeyDown(keyCode: Int, event: KeyEvent!): Boolean
| Parameters |
keyCode |
Int: a key code that represents the button pressed, from android.view.KeyEvent |
event |
KeyEvent!: the KeyEvent object that defines the button action |
| Return |
| Boolean: If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |
onKeyMultiple
open fun onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!): Boolean
| Parameters |
keyCode |
Int: A key code that represents the button pressed, from android.view.KeyEvent. |
count |
Number of pairs as returned by event.getRepeatCount(). |
event |
KeyEvent!: The KeyEvent object that defines the button action. |
repeatCount |
Int: The number of times the action was made. |
| Return |
| Boolean: If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |
onKeyPreIme
open fun onKeyPreIme(keyCode: Int, event: KeyEvent!): Boolean
| Parameters |
keyCode |
Int: The value in event.getKeyCode(). |
event |
KeyEvent!: Description of the key event. |
| Return |
| Boolean: If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |
onKeyShortcut
open fun onKeyShortcut(keyCode: Int, event: KeyEvent!): Boolean
| Parameters |
keyCode |
Int: The value in event.getKeyCode(). |
event |
KeyEvent!: Description of the key event. |
| Return |
| Boolean: If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |
onKeyUp
open fun onKeyUp(keyCode: Int, event: KeyEvent!): Boolean
| Parameters |
keyCode |
Int: A key code that represents the button pressed, from android.view.KeyEvent. |
event |
KeyEvent!: The KeyEvent object that defines the button action. |
| Return |
| Boolean: If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |
onPreDraw
open fun onPreDraw(): Boolean
Callback method to be invoked when the view tree is about to be drawn. At this point, all views in the tree have been measured and given a frame. Clients can use this to adjust their scroll bounds or even to request a new layout before drawing occurs.
| Return |
| Boolean: Return true to proceed with the current drawing pass, or false to cancel. |
onPrivateIMECommand
open fun onPrivateIMECommand(action: String!, data: Bundle!): Boolean
Called by the framework in response to a private command from the current method, provided by it calling InputConnection#performPrivateCommand.
| Parameters |
action |
String!: The action name of the command. |
data |
Bundle!: Any additional data for the command. This may be null. |
| Return |
| Boolean: Return true if you handled the command, else false. |
onRestoreInstanceState
open fun onRestoreInstanceState(state: Parcelable!): Unit
onRtlPropertiesChanged
open fun onRtlPropertiesChanged(layoutDirection: Int): Unit
onSaveInstanceState
open fun onSaveInstanceState(): Parcelable?
| Return |
| Parcelable?: Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save. |
onScreenStateChanged
open fun onScreenStateChanged(screenState: Int): Unit
onTouchEvent
open fun onTouchEvent(event: MotionEvent!): Boolean
| Return |
| Boolean: True if the event was handled, false otherwise. |
onTrackballEvent
open fun onTrackballEvent(event: MotionEvent!): Boolean
| Return |
| Boolean: True if the event was handled, false otherwise. |
onWindowFocusChanged
open fun onWindowFocusChanged(hasWindowFocus: Boolean): Unit
| Parameters |
hasWindowFocus |
Boolean: True if the window containing this view now has focus, false otherwise. |
performLongClick
open fun performLongClick(): Boolean
| Return |
Boolean: true if one of the above receivers consumed the event, false otherwise |
removeTextChangedListener
open fun removeTextChangedListener(watcher: TextWatcher!): Unit
Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.
setAllCaps
open fun setAllCaps(allCaps: Boolean): Unit
Sets the properties of this field to transform input to ALL CAPS display. This may use a "small caps" formatting if available. This setting will be ignored if this field is editable or selectable. This call replaces the current transformation method. Disabling this will not necessarily restore the previous behavior from before this was enabled.
setAutoLinkMask
fun setAutoLinkMask(mask: Int): Unit
Sets the autolink mask of the text. See and peers for possible values.
Note: Linkify.MAP_ADDRESSES is deprecated and should be avoided; see its documentation.
setAutoSizeTextTypeUniformWithConfiguration
open fun setAutoSizeTextTypeUniformWithConfiguration(autoSizeMinTextSize: Int, autoSizeMaxTextSize: Int, autoSizeStepGranularity: Int, unit: Int): Unit
Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. If all the configuration params are valid the type of auto-size is set to AUTO_SIZE_TEXT_TYPE_UNIFORM.
| Parameters |
autoSizeMinTextSize |
Int: the minimum text size available for auto-size |
autoSizeMaxTextSize |
Int: the maximum text size available for auto-size |
autoSizeStepGranularity |
Int: the auto-size step granularity. It is used in conjunction with the minimum and maximum text size in order to build the set of text sizes the system uses to choose from when auto-sizing |
unit |
Int: the desired dimension unit for all sizes above. See TypedValue for the possible dimension units |
| Exceptions |
java.lang.IllegalArgumentException |
if any of the configuration params are invalid. |
setAutoSizeTextTypeUniformWithPresetSizes
open fun setAutoSizeTextTypeUniformWithPresetSizes(presetSizes: IntArray, unit: Int): Unit
Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. If at least one value from the presetSizes is valid then the type of auto-size is set to AUTO_SIZE_TEXT_TYPE_UNIFORM.
| Parameters |
presetSizes |
IntArray: an int array of sizes in pixels This value must never be null. |
unit |
Int: the desired dimension unit for the preset sizes above. See TypedValue for the possible dimension units |
| Exceptions |
java.lang.IllegalArgumentException |
if all of the presetSizes are invalid. |
setAutoSizeTextTypeWithDefaults
open fun setAutoSizeTextTypeWithDefaults(autoSizeTextType: Int): Unit
Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds by using the default auto-size configuration.
| Exceptions |
java.lang.IllegalArgumentException |
if autoSizeTextType is none of the types above. |
setCompoundDrawablePadding
open fun setCompoundDrawablePadding(pad: Int): Unit
Sets the size of the padding between the compound drawables and the text.
setCompoundDrawables
open fun setCompoundDrawables(left: Drawable?, top: Drawable?, right: Drawable?, bottom: Drawable?): Unit
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had Drawable#setBounds called.
Calling this method will overwrite any Drawables previously set using setCompoundDrawablesRelative or related methods.
| Parameters |
left |
Drawable?: This value may be null. |
top |
Drawable?: This value may be null. |
right |
Drawable?: This value may be null. |
bottom |
Drawable?: This value may be null. |
setCompoundDrawablesRelative
open fun setCompoundDrawablesRelative(start: Drawable?, top: Drawable?, end: Drawable?, bottom: Drawable?): Unit
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had Drawable#setBounds called.
Calling this method will overwrite any Drawables previously set using setCompoundDrawables or related methods.
| Parameters |
start |
Drawable?: This value may be null. |
top |
Drawable?: This value may be null. |
end |
Drawable?: This value may be null. |
bottom |
Drawable?: This value may be null. |
setCompoundDrawablesRelativeWithIntrinsicBounds
open fun setCompoundDrawablesRelativeWithIntrinsicBounds(start: Int, top: Int, end: Int, bottom: Int): Unit
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.
Calling this method will overwrite any Drawables previously set using setCompoundDrawables or related methods.
| Parameters |
start |
Int: Resource identifier of the start Drawable. |
top |
Int: Resource identifier of the top Drawable. |
end |
Int: Resource identifier of the end Drawable. |
bottom |
Int: Resource identifier of the bottom Drawable. |
setCompoundDrawablesRelativeWithIntrinsicBounds
open fun setCompoundDrawablesRelativeWithIntrinsicBounds(start: Drawable?, top: Drawable?, end: Drawable?, bottom: Drawable?): Unit
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Use null if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.
Calling this method will overwrite any Drawables previously set using setCompoundDrawables or related methods.
| Parameters |
start |
Drawable?: This value may be null. |
top |
Drawable?: This value may be null. |
end |
Drawable?: This value may be null. |
bottom |
Drawable?: This value may be null. |
setCompoundDrawablesWithIntrinsicBounds
open fun setCompoundDrawablesWithIntrinsicBounds(left: Int, top: Int, right: Int, bottom: Int): Unit
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.
Calling this method will overwrite any Drawables previously set using setCompoundDrawablesRelative or related methods.
| Parameters |
left |
Int: Resource identifier of the left Drawable. |
top |
Int: Resource identifier of the top Drawable. |
right |
Int: Resource identifier of the right Drawable. |
bottom |
Int: Resource identifier of the bottom Drawable. |
setCompoundDrawablesWithIntrinsicBounds
open fun setCompoundDrawablesWithIntrinsicBounds(left: Drawable?, top: Drawable?, right: Drawable?, bottom: Drawable?): Unit
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.
Calling this method will overwrite any Drawables previously set using setCompoundDrawablesRelative or related methods.
| Parameters |
left |
Drawable?: This value may be null. |
top |
Drawable?: This value may be null. |
right |
Drawable?: This value may be null. |
bottom |
Drawable?: This value may be null. |
setCursorVisible
open fun setCursorVisible(visible: Boolean): Unit
Set whether the cursor is visible. The default is true. Note that this property only makes sense for editable TextView.
setCustomSelectionActionModeCallback
open fun setCustomSelectionActionModeCallback(actionModeCallback: ActionMode.Callback!): Unit
If provided, this ActionMode.Callback will be used to create the ActionMode when text selection is initiated in this View.
The standard implementation populates the menu with a subset of Select All, Cut, Copy, Paste, Replace and Share actions, depending on what this View supports.
A custom implementation can add new entries in the default menu in its android.view.ActionMode.Callback#onPrepareActionMode(ActionMode, android.view.Menu) method. The default actions can also be removed from the menu using android.view.Menu#removeItem(int) and passing android.R.id#selectAll, android.R.id#cut, android.R.id#copy, android.R.id#paste, android.R.id#replaceText or android.R.id#shareText ids as parameters.
Returning false from android.view.ActionMode.Callback#onCreateActionMode(ActionMode, android.view.Menu) will prevent the action mode from being started.
Action click events should be handled by the custom implementation of android.view.ActionMode.Callback#onActionItemClicked(ActionMode, * android.view.MenuItem).
Note that text selection mode is not started when a TextView receives focus and the android.R.attr#selectAllOnFocus flag has been set. The content is highlighted in that case, to allow for quick replacement.
setElegantTextHeight
open fun setElegantTextHeight(elegant: Boolean): Unit
Set the TextView's elegant height metrics flag. This setting selects font variants that have not been compacted to fit Latin-based vertical metrics, and also increases top and bottom bounds to provide more space.
| Parameters |
elegant |
Boolean: set the paint's elegant metrics flag. |
setEms
open fun setEms(ems: Int): Unit
Sets the width of the TextView to be exactly ems wide. This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous minimum/maximum configurations such as setMinEms(int) or setMaxEms(int).
| Parameters |
ems |
Int: the exact width of the TextView in terms of ems |
setEnabled
open fun setEnabled(enabled: Boolean): Unit
| Parameters |
enabled |
Boolean: True if this view is enabled, false otherwise. |
setError
open fun setError(error: CharSequence!): Unit
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. The icon and error message will be reset to null when any key events cause changes to the TextView's text. If the error is null, the error message and icon will be cleared.
setError
open fun setError(error: CharSequence!, icon: Drawable!): Unit
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. The icon and error message will be reset to null when any key events cause changes to the TextView's text. The drawable must already have had Drawable#setBounds set on it. If the error is null, the error message will be cleared (and you should provide a null icon as well).
setFallbackLineSpacing
open fun setFallbackLineSpacing(enabled: Boolean): Unit
Set whether to respect the ascent and descent of the fallback fonts that are used in displaying the text (which is needed to avoid text from consecutive lines running into each other). If set, fallback fonts that end up getting used can increase the ascent and descent of the lines that they are used on.
It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.
| Parameters |
enabled |
Boolean: whether to expand linespacing based on fallback fonts, true by default |
setFilters
open fun setFilters(filters: Array<InputFilter!>!): Unit
Sets the list of input filters that will be used if the buffer is Editable. Has no effect otherwise.
setFirstBaselineToTopHeight
open fun setFirstBaselineToTopHeight(firstBaselineToTopHeight: Int): Unit
Updates the top padding of the TextView so that is the distance between the top of the TextView and first line's baseline.
First and last baseline metrics for a TextView.
Note that if
FontMetrics.top or
FontMetrics.ascent was already greater than
firstBaselineToTopHeight, the top padding is not updated. Moreover since this function sets the top padding, if the height of the TextView is less than the sum of top padding, line height and bottom padding, top of the line will be pushed down and bottom will be clipped.
| Parameters |
firstBaselineToTopHeight |
Int: distance between first baseline to top of the container in pixels This units of this value are pixels. Value is 0 or greater |
setFontVariationSettings
open fun setFontVariationSettings(fontVariationSettings: String?): Boolean
Sets TrueType or OpenType font variation settings. The settings string is constructed from multiple pairs of axis tag and style values. The axis tag must contain four ASCII characters and must be wrapped with single quotes (U+0027) or double quotes (U+0022). Axis strings that are longer or shorter than four characters, or contain characters outside of U+0020..U+007E are invalid. If a specified axis name is not defined in the font, the settings will be ignored.
Examples,
- Set font width to 150.
<code>
TextView textView = (TextView) findViewById(R.id.textView);
textView.setFontVariationSettings("'wdth' 150");
</code>
- Set the font slant to 20 degrees and ask for italic style.
<code>
TextView textView = (TextView) findViewById(R.id.textView);
textView.setFontVariationSettings("'slnt' 20, 'ital' 1");
</code>
| Parameters |
fontVariationSettings |
String?: font variation settings. You can pass null or empty string as no variation settings. This value may be null. |
| Return |
| Boolean: true if the given settings is effective to at least one font file underlying this TextView. This function also returns true for empty settings string. Otherwise returns false. |
| Exceptions |
java.lang.IllegalArgumentException |
If given string is not a valid font variation settings format. |
setFreezesText
open fun setFreezesText(freezesText: Boolean): Unit
Control whether this text view saves its entire text contents when freezing to an icicle, in addition to dynamic state such as cursor position. By default this is false, not saving the text. Set to true if the text in the text view is not being saved somewhere else in persistent storage (such as in a content provider) so that if the view is later thawed the user will not lose their data. For android.widget.EditText it is always enabled, regardless of the value of the attribute.
| Parameters |
freezesText |
Boolean: Controls whether a frozen icicle should include the entire text data: true to include it, false to not. |
setGravity
open fun setGravity(gravity: Int): Unit
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.
setHeight
open fun setHeight(pixels: Int): Unit
Sets the height of the TextView to be exactly pixels tall.
This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous minimum/maximum height configurations such as setMinHeight(int) or setMaxHeight(int).
| Parameters |
pixels |
Int: the exact height of the TextView in terms of pixels |
setHighlightColor
open fun setHighlightColor(color: Int): Unit
Sets the color used to display the selection highlight.
setHint
fun setHint(hint: CharSequence!): Unit
Sets the text to be displayed when the text of the TextView is empty. Null means to use the normal empty text. The hint does not currently participate in determining the size of the view.
setHint
fun setHint(resid: Int): Unit
Sets the text to be displayed when the text of the TextView is empty, from a resource.
setHintTextColor
fun setHintTextColor(color: Int): Unit
Sets the color of the hint text for all the states (disabled, focussed, selected...) of this TextView.
setHintTextColor
fun setHintTextColor(colors: ColorStateList!): Unit
Sets the color of the hint text.
setHorizontallyScrolling
open fun setHorizontallyScrolling(whether: Boolean): Unit
Sets whether the text should be allowed to be wider than the View is. If false, it will be wrapped to the width of the View.
setImeHintLocales
open fun setImeHintLocales(hintLocales: LocaleList?): Unit
Change "hint" locales associated with the text view, which will be reported to an IME with EditorInfo#hintLocales when it has focus. Starting with Android O, this also causes internationalized listeners to be created (or change locale) based on the first locale in the input locale list.
Note: If you want new "hint" to take effect immediately you need to call InputMethodManager#restartInput(View).
| Parameters |
hintLocales |
LocaleList?: List of the languages that the user is supposed to switch to no matter what input method subtype is currently used. Set null to clear the current "hint". This value may be null. |
setImeOptions
open fun setImeOptions(imeOptions: Int): Unit
Change the editor type integer associated with the text view, which is reported to an Input Method Editor (IME) with EditorInfo#imeOptions when it has focus.
setIncludeFontPadding
open fun setIncludeFontPadding(includepad: Boolean): Unit
Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent. The default is true.
setInputExtras
open fun setInputExtras(xmlResId: Int): Unit
Set the extra input data of the text, which is the EditorInfo#extras Bundle that will be filled in when creating an input connection. The given integer is the resource identifier of an XML resource holding an <input-extras> XML tree.
setKeyListener
open fun setKeyListener(input: KeyListener!): Unit
Sets the key listener to be used with this TextView. This can be null to disallow user input. Note that this method has significant and subtle interactions with soft keyboards and other input method: see KeyListener#getInputType() for important details. Calling this method will replace the current content type of the text view with the content type returned by the key listener.
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 again after calling this to get the focusability back the way you want it.
setLastBaselineToBottomHeight
open fun setLastBaselineToBottomHeight(lastBaselineToBottomHeight: Int): Unit
Updates the bottom padding of the TextView so that is the distance between the bottom of the TextView and the last line's baseline.
First and last baseline metrics for a TextView.
Note that if
FontMetrics.bottom or
FontMetrics.descent was already greater than
lastBaselineToBottomHeight, the bottom padding is not updated. Moreover since this function sets the bottom padding, if the height of the TextView is less than the sum of top padding, line height and bottom padding, bottom of the text will be clipped.
| Parameters |
lastBaselineToBottomHeight |
Int: distance between last baseline to bottom of the container in pixels This units of this value are pixels. Value is 0 or greater |
setLetterSpacing
open fun setLetterSpacing(letterSpacing: Float): Unit
Sets text letter-spacing in em units. Typical values for slight expansion will be around 0.05. Negative values tighten text.
| Parameters |
letterSpacing |
Float: A text letter-space value in ems. |
setLineHeight
open fun setLineHeight(lineHeight: Int): Unit
Sets an explicit line height for this TextView. This is equivalent to the vertical distance between subsequent baselines in the TextView.
| Parameters |
lineHeight |
Int: the line height in pixels This units of this value are pixels. Value is 0 or greater |
setLineSpacing
open fun setLineSpacing(add: Float, mult: Float): Unit
Sets line spacing for this TextView. Each line other than the last line will have its height multiplied by mult and have add added to it.
| Parameters |
add |
Float: The value in pixels that should be added to each line other than the last line. This will be applied after the multiplier |
mult |
Float: The value by which each line height other than the last line will be multiplied by |
setLines
open fun setLines(lines: Int): Unit
Sets the height of the TextView to be exactly lines tall.
This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous minimum/maximum height configurations such as setMinLines(int) or setMaxLines(int). setSingleLine() will set this value to 1.
| Parameters |
lines |
Int: the exact height of the TextView in terms of lines |
setLinkTextColor
fun setLinkTextColor(color: Int): Unit
Sets the color of links in the text.
setLinkTextColor
fun setLinkTextColor(colors: ColorStateList!): Unit
Sets the color of links in the text.
setMarqueeRepeatLimit
open fun setMarqueeRepeatLimit(marqueeLimit: Int): Unit
Sets how many times to repeat the marquee animation. Only applied if the TextView has marquee enabled. Set to -1 to repeat indefinitely.
setMaxEms
open fun setMaxEms(maxEms: Int): Unit
Sets the width of the TextView to be at most maxEms wide.
This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous maximum width configurations such as setMaxWidth(int) or setWidth(int).
| Parameters |
maxEms |
Int: the maximum width of TextView in terms of ems |
setMaxHeight
open fun setMaxHeight(maxPixels: Int): Unit
Sets the height of the TextView to be at most maxPixels tall.
This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous maximum height configurations such as setMaxLines(int) or setLines(int).
| Parameters |
maxPixels |
Int: the maximum height of TextView in terms of pixels |
setMaxLines
open fun setMaxLines(maxLines: Int): Unit
Sets the height of the TextView to be at most maxLines tall.
This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous maximum height configurations such as setMaxHeight(int) or setLines(int).
| Parameters |
maxLines |
Int: the maximum height of TextView in terms of number of lines |
setMaxWidth
open fun setMaxWidth(maxPixels: Int): Unit
Sets the width of the TextView to be at most maxPixels wide.
This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous maximum width configurations such as setMaxEms(int) or setEms(int).
| Parameters |
maxPixels |
Int: the maximum width of TextView in terms of pixels |
setMinEms
open fun setMinEms(minEms: Int): Unit
Sets the width of the TextView to be at least minEms wide.
This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous minimum width configurations such as setMinWidth(int) or setWidth(int).
| Parameters |
minEms |
Int: the minimum width of TextView in terms of ems |
setMinHeight
open fun setMinHeight(minPixels: Int): Unit
Sets the height of the TextView to be at least minPixels tall.
This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous minimum height configurations such as setMinLines(int) or setLines(int).
The value given here is different than setMinimumHeight(int). Between minHeight and the value set in setMinimumHeight(int), the greater one is used to decide the final height.
| Parameters |
minPixels |
Int: the minimum height of TextView in terms of pixels |
setMinLines
open fun setMinLines(minLines: Int): Unit
Sets the height of the TextView to be at least minLines tall.
This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides other previous minimum height configurations such as setMinHeight(int) or setHeight(int). setSingleLine() will set this value to 1.
| Parameters |
minLines |
Int: the minimum height of TextView in terms of number of lines |
setMinWidth
open fun setMinWidth(minPixels: Int): Unit
Sets the width of the TextView to be at least minPixels wide.
This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous minimum width configurations such as setMinEms(int) or setEms(int).
The value given here is different than setMinimumWidth(int). Between minWidth and the value set in setMinimumWidth(int), the greater one is used to decide the final width.
| Parameters |
minPixels |
Int: the minimum width of TextView in terms of pixels |
setMovementMethod
fun setMovementMethod(movement: MovementMethod!): Unit
Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView. This can be null to disallow using the arrow keys to move the cursor or scroll the view.
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 again after calling this to get the focusability back the way you want it.
setOnEditorActionListener
open fun setOnEditorActionListener(l: TextView.OnEditorActionListener!): Unit
Set a special listener to be called when an action is performed on the text view. This will be called when the enter key is pressed, or when an action supplied to the IME is selected by the user. Setting this means that the normal hard key event will not insert a newline into the text view, even if it is multi-line; holding down the ALT modifier will, however, allow the user to insert a newline character.
setPadding
open fun setPadding(left: Int, top: Int, right: Int, bottom: Int): Unit
| Parameters |
left |
Int: the left padding in pixels |
top |
Int: the top padding in pixels |
right |
Int: the right padding in pixels |
bottom |
Int: the bottom padding in pixels |
setPaddingRelative
open fun setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int): Unit
| Parameters |
start |
Int: the start padding in pixels |
top |
Int: the top padding in pixels |
end |
Int: the end padding in pixels |
bottom |
Int: the bottom padding in pixels |
setPaintFlags
open fun setPaintFlags(flags: Int): Unit
Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.
setPrivateImeOptions
open fun setPrivateImeOptions(type: String!): Unit
Set the private content type of the text, which is the EditorInfo#privateImeOptions field that will be filled in when creating an input connection.
setRawInputType
open fun setRawInputType(type: Int): Unit
Directly change the content type integer of the text view, without modifying any other state.
setScroller
open fun setScroller(s: Scroller!): Unit
Sets the Scroller used for producing a scrolling animation
| Parameters |
s |
Scroller!: A Scroller instance |
setSelectAllOnFocus
open fun setSelectAllOnFocus(selectAllOnFocus: Boolean): Unit
Set the TextView so that when it takes focus, all the text is selected.
setSelected
open fun setSelected(selected: Boolean): Unit
| Parameters |
selected |
Boolean: true if the view must be selected, false otherwise |
setShadowLayer
open fun setShadowLayer(radius: Float, dx: Float, dy: Float, color: Int): Unit
Gives the text a shadow of the specified blur radius and color, the specified distance from its drawn position.
The text shadow produced does not interact with the properties on view that are responsible for real time shadows, View#getElevation() and View#getTranslationZ().
setShowSoftInputOnFocus
fun setShowSoftInputOnFocus(show: Boolean): Unit
Sets whether the soft input method will be made visible when this TextView gets focused. The default is true.
setSingleLine
open fun setSingleLine(): Unit
Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.
setSingleLine
open fun setSingleLine(singleLine: Boolean): Unit
If true, sets the properties of this field (number of lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions. Note that the default conditions are not necessarily those that were in effect prior this method, and you may want to reset these properties to your custom values.
setText
fun setText(text: CharSequence!): Unit
Sets the text to be displayed. TextView does not accept HTML-like formatting, which you can do with text strings in XML resource files. To style your strings, attach android.text.style.* objects to a android.text.SpannableString, or see the Available Resource Types documentation for an example of setting formatted text in the XML resource file.
When required, TextView will use
android.text.Spannable.Factory to create final or intermediate
Spannable. Likewise it will use
android.text.Editable.Factory to create final or intermediate
Editable. If the passed text is a
PrecomputedText but the parameters used to create the PrecomputedText mismatches with this TextView, IllegalArgumentException is thrown. To ensure the parameters match, you can call
TextView#setTextMetricsParams before calling this.
| Exceptions |
java.lang.IllegalArgumentException |
if the passed text is a PrecomputedText but the parameters used to create the PrecomputedText mismatches with this TextView. |
setText
fun setText(text: CharArray!, start: Int, len: Int): Unit
Sets the TextView to display the specified slice of the specified char array. You must promise that you will not change the contents of the array except for right before another call to setText(), since the TextView has no way to know that the text has changed and that it needs to invalidate and re-layout.
| Parameters |
text |
CharArray!: char array to be displayed |
start |
Int: start index in the char array |
len |
Int: length of char count after start |
setText
fun setText(resid: Int): Unit
Sets the text to be displayed using a string resource identifier.
| Parameters |
resid |
Int: the resource identifier of the string resource to be displayed |
setTextAppearance
open fun setTextAppearance(resId: Int): Unit
Sets the text appearance from the specified style resource.
Use a framework-defined TextAppearance style like @android:style/TextAppearance.Material.Body1 or see TextAppearance for the set of attributes that can be used in a custom style.
| Parameters |
resId |
Int: the resource identifier of the style to apply |
setTextAppearance
open fun setTextAppearance(context: Context!, resId: Int): Unit
Deprecated: Use setTextAppearance(int) instead.
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
setTextColor
open fun setTextColor(color: Int): Unit
Sets the text color for all the states (normal, selected, focused) to be this color.
| Parameters |
color |
Int: A color value in the form 0xAARRGGBB. Do not pass a resource ID. To get a color value from a resource ID, call android.support.v4.content.ContextCompat#getColor(Context, int). |
setTextCursorDrawable
open fun setTextCursorDrawable(textCursorDrawable: Drawable?): Unit
Sets the Drawable corresponding to the text cursor. The Drawable defaults to the value of the textCursorDrawable attribute. Note that any change applied to the cursor Drawable will not be visible until the cursor is hidden and then drawn again.
| Parameters |
textCursorDrawable |
Drawable?: This value may be null. |
setTextCursorDrawable
open fun setTextCursorDrawable(textCursorDrawable: Int): Unit
Sets the Drawable corresponding to the text cursor. The Drawable defaults to the value of the textCursorDrawable attribute. Note that any change applied to the cursor Drawable will not be visible until the cursor is hidden and then drawn again.
setTextIsSelectable
open fun setTextIsSelectable(selectable: Boolean): Unit
Sets whether the content of this view is selectable by the user. The default is false, meaning that the content is not selectable.
When you use a TextView to display a useful piece of information to the user (such as a contact's address), make it selectable, so that the user can select and copy its content. You can also use set the XML attribute android.R.styleable#TextView_textIsSelectable to "true".
When you call this method to set the value of textIsSelectable, it sets the flags focusable, focusableInTouchMode, clickable, and longClickable to the same value. These flags correspond to the attributes android:focusable, android:focusableInTouchMode, android:clickable, and android:longClickable. To restore any of these flags to a state you had set previously, call one or more of the following methods: setFocusable(), setFocusableInTouchMode(), setClickable() or setLongClickable().
| Parameters |
selectable |
Boolean: Whether the content of this TextView should be selectable. |
setTextLocale
open fun setTextLocale(locale: Locale): Unit
Set the default Locale of the text in this TextView to a one-member LocaleList containing just the given Locale.
| Parameters |
locale |
Locale: the Locale for drawing text, must not be null. This value must never be null. |
setTextLocales
open fun setTextLocales(locales: LocaleList): Unit
Set the default LocaleList of the text in this TextView to the given value. This value is used to choose appropriate typefaces for ambiguous characters (typically used for CJK locales to disambiguate Hanzi/Kanji/Hanja characters). It also affects other aspects of text display, including line breaking.
| Parameters |
locales |
LocaleList: the LocaleList for drawing text, must not be null or empty. This value must never be null. |
setTextScaleX
open fun setTextScaleX(size: Float): Unit
Sets the horizontal scale factor for text. The default value is 1.0. Values greater than 1.0 stretch the text wider. Values less than 1.0 make the text narrower. By default, this value is 1.0.
| Parameters |
size |
Float: The horizontal scale factor. |
setTextSelectHandle
open fun setTextSelectHandle(textSelectHandle: Drawable): Unit
Sets the Drawable corresponding to the selection handle used for positioning the cursor within text. The Drawable defaults to the value of the textSelectHandle attribute. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
| Parameters |
textSelectHandle |
Drawable: This value must never be null. |
setTextSelectHandle
open fun setTextSelectHandle(textSelectHandle: Int): Unit
Sets the Drawable corresponding to the selection handle used for positioning the cursor within text. The Drawable defaults to the value of the textSelectHandle attribute. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
setTextSelectHandleLeft
open fun setTextSelectHandleLeft(textSelectHandleLeft: Drawable): Unit
Sets the Drawable corresponding to the left handle used for selecting text. The Drawable defaults to the value of the textSelectHandleLeft attribute. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
| Parameters |
textSelectHandleLeft |
Drawable: This value must never be null. |
setTextSelectHandleLeft
open fun setTextSelectHandleLeft(textSelectHandleLeft: Int): Unit
Sets the Drawable corresponding to the left handle used for selecting text. The Drawable defaults to the value of the textSelectHandleLeft attribute. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
setTextSelectHandleRight
open fun setTextSelectHandleRight(textSelectHandleRight: Drawable): Unit
Sets the Drawable corresponding to the right handle used for selecting text. The Drawable defaults to the value of the textSelectHandleRight attribute. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
| Parameters |
textSelectHandleRight |
Drawable: This value must never be null. |
setTextSelectHandleRight
open fun setTextSelectHandleRight(textSelectHandleRight: Int): Unit
Sets the Drawable corresponding to the right handle used for selecting text. The Drawable defaults to the value of the textSelectHandleRight attribute. Note that any change applied to the handle Drawable will not be visible until the handle is hidden and then drawn again.
setTextSize
open fun setTextSize(size: Float): Unit
Set the default text size to the given value, interpreted as "scaled pixel" units. This size is adjusted based on the current density and user font size preference.
Note: if this TextView has the auto-size feature enabled than this function is no-op.
| Parameters |
size |
Float: The scaled pixel size. |
setTextSize
open fun setTextSize(unit: Int, size: Float): Unit
Set the default text size to a given unit and value. See TypedValue for the possible dimension units.
Note: if this TextView has the auto-size feature enabled than this function is no-op.
| Parameters |
unit |
Int: The desired dimension unit. |
size |
Float: The desired size in the given units. |
setTransformationMethod
fun setTransformationMethod(method: TransformationMethod!): Unit
Sets the transformation that is applied to the text that this TextView is displaying.
setTypeface
open fun setTypeface(tf: Typeface?, style: Int): Unit
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.
setTypeface
open fun setTypeface(tf: Typeface?): Unit
Sets the typeface and style in which the text should be displayed. Note that not all Typeface families actually have bold and italic variants, so you may need to use setTypeface(android.graphics.Typeface,int) to get the appearance that you actually want.
| Parameters |
tf |
Typeface?: This value may be null. |
setWidth
open fun setWidth(pixels: Int): Unit
Sets the width of the TextView to be exactly pixels wide.
This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous minimum/maximum width configurations such as setMinWidth(int) or setMaxWidth(int).
| Parameters |
pixels |
Int: the exact width of the TextView in terms of pixels |
showContextMenu
open fun showContextMenu(): Boolean
| Return |
Boolean: true if the context menu was shown, false otherwise |
showContextMenu
open fun showContextMenu(x: Float, y: Float): Boolean
| Parameters |
x |
Float: the X coordinate in pixels relative to the view to which the menu should be anchored, or Float#NaN to disable anchoring |
y |
Float: the Y coordinate in pixels relative to the view to which the menu should be anchored, or Float#NaN to disable anchoring |
| Return |
Boolean: true if the context menu was shown, false otherwise |
Protected methods
computeHorizontalScrollRange
protected open fun computeHorizontalScrollRange(): Int
| Return |
| Int: the total horizontal range represented by the horizontal scrollbar |
computeVerticalScrollExtent
protected open fun computeVerticalScrollExtent(): Int
| Return |
| Int: the vertical extent of the scrollbar's thumb |
computeVerticalScrollRange
protected open fun computeVerticalScrollRange(): Int
| Return |
| Int: the total vertical range represented by the vertical scrollbar
The default range is the drawing height of this view.
|
drawableStateChanged
protected open fun drawableStateChanged(): Unit
getBottomPaddingOffset
protected open fun getBottomPaddingOffset(): Int
| Return |
| Int: The bottom padding offset in pixels. |
getDefaultEditable
protected open fun getDefaultEditable(): Boolean
Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.
getDefaultMovementMethod
protected open fun getDefaultMovementMethod(): MovementMethod!
Subclasses override this to specify a default movement method.
getLeftFadingEdgeStrength
protected open fun getLeftFadingEdgeStrength(): Float
| Return |
| Float: the intensity of the left fade as a float between 0.0f and 1.0f |
getLeftPaddingOffset
protected open fun getLeftPaddingOffset(): Int
| Return |
| Int: The left padding offset in pixels. |
getRightFadingEdgeStrength
protected open fun getRightFadingEdgeStrength(): Float
| Return |
| Float: the intensity of the right fade as a float between 0.0f and 1.0f |
getRightPaddingOffset
protected open fun getRightPaddingOffset(): Int
| Return |
| Int: The right padding offset in pixels. |
getTopPaddingOffset
protected open fun getTopPaddingOffset(): Int
| Return |
| Int: The top padding offset in pixels. |
isPaddingOffsetRequired
protected open fun isPaddingOffsetRequired(): Boolean
| Return |
| Boolean: True if padding offset must be applied, false otherwise. |
onAttachedToWindow
protected open fun onAttachedToWindow(): Unit
onConfigurationChanged
protected open fun onConfigurationChanged(newConfig: Configuration!): Unit
| Parameters |
newConfig |
Configuration!: The new resource configuration. |
onCreateContextMenu
protected open fun onCreateContextMenu(menu: ContextMenu!): Unit
| Parameters |
menu |
ContextMenu!: the context menu to populate |
onCreateDrawableState
protected open fun onCreateDrawableState(extraSpace: Int): IntArray!
| Parameters |
extraSpace |
Int: if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states. |
| Return |
IntArray!: Returns an array holding the current Drawable state of the view. |
onDraw
protected open fun onDraw(canvas: Canvas!): Unit
| Parameters |
canvas |
Canvas!: the canvas on which the background will be drawn |
onFocusChanged
protected open fun onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?): Unit
| Parameters |
gainFocus |
True if the View has focus; false otherwise. |
direction |
Int: The direction focus has moved when requestFocus() is called to give this view focus. Values are FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, or FOCUS_BACKWARD. It may not always apply, in which case use the default. Value is android.view.View#FOCUS_BACKWARD, android.view.View#FOCUS_FORWARD, android.view.View#FOCUS_LEFT, android.view.View#FOCUS_UP, android.view.View#FOCUS_RIGHT, or android.view.View#FOCUS_DOWN |
previouslyFocusedRect |
Rect?: 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. This value may be null. |
onLayout
protected open fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit
| Parameters |
changed |
Boolean: This is a new size or position for this view |
left |
Int: Left position, relative to parent |
top |
Int: Top position, relative to parent |
right |
Int: Right position, relative to parent |
bottom |
Int: Bottom position, relative to parent |
onMeasure
protected open fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit
onScrollChanged
protected open fun onScrollChanged(horiz: Int, vert: Int, oldHoriz: Int, oldVert: Int): Unit
| Parameters |
l |
Current horizontal scroll origin. |
t |
Current vertical scroll origin. |
oldl |
Previous horizontal scroll origin. |
oldt |
Previous vertical scroll origin. |
onSelectionChanged
protected open fun onSelectionChanged(selStart: Int, selEnd: Int): Unit
This method is called when the selection has changed, in case any subclasses would like to know.
| Parameters |
selStart |
Int: The new selection start location. |
selEnd |
Int: The new selection end location. |
onTextChanged
protected open fun onTextChanged(text: CharSequence!, start: Int, lengthBefore: Int, lengthAfter: Int): Unit
This method is called when the text is changed, in case any subclasses would like to know. Within text, the lengthAfter characters beginning at start have just replaced old text that had length lengthBefore. It is an error to attempt to make changes to text from this callback.
| Parameters |
text |
CharSequence!: The text the TextView is displaying |
start |
Int: The offset of the start of the range of the text that was modified |
lengthBefore |
Int: The length of the former text that has been replaced |
lengthAfter |
Int: The length of the replacement modified text |
onVisibilityChanged
protected open fun onVisibilityChanged(changedView: View, visibility: Int): Unit
verifyDrawable
protected open fun verifyDrawable(who: Drawable): Boolean
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.
Be sure to call through to the super class when overriding this function.
If you override this method you must call through to the superclass implementation.
| Parameters |
who |
Drawable: This value must never be null. |
| Return |
| Boolean: boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate. |