belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
TextViewCompat
  public
  
  final
  
  class
  TextViewCompat
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.support.v4.widget.TextViewCompat | 
Helper for accessing features in TextView.
Summary
| Constants | |
|---|---|
| int | AUTO_SIZE_TEXT_TYPE_NONEThe TextView does not auto-size text (default). | 
| int | AUTO_SIZE_TEXT_TYPE_UNIFORMThe TextView scales text size both horizontally and vertically to fit within the container. | 
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        int | 
      getAutoSizeMaxTextSize(TextView textView)
       | 
| 
        
        
        static
        
        
        int | 
      getAutoSizeMinTextSize(TextView textView)
       | 
| 
        
        
        static
        
        
        int | 
      getAutoSizeStepGranularity(TextView textView)
       | 
| 
        
        
        static
        
        
        int[] | 
      getAutoSizeTextAvailableSizes(TextView textView)
       | 
| 
        
        
        static
        
        
        int | 
      getAutoSizeTextType(TextView textView)
      Returns the type of auto-size set for this widget. | 
| 
        
        
        static
        
        
        Drawable[] | 
      getCompoundDrawablesRelative(TextView textView)
      Returns drawables for the start, top, end, and bottom borders from the given text view. | 
| 
        
        
        static
        
        
        int | 
      getMaxLines(TextView textView)
      Returns the maximum number of lines displayed in the given TextView, or -1 if the maximum height was set in pixels instead. | 
| 
        
        
        static
        
        
        int | 
      getMinLines(TextView textView)
      Returns the minimum number of lines displayed in the given TextView, or -1 if the minimum height was set in pixels instead. | 
| 
        
        
        static
        
        
        void | 
      setAutoSizeTextTypeUniformWithConfiguration(TextView textView, int autoSizeMinTextSize, int autoSizeMaxTextSize, int autoSizeStepGranularity, int unit)
      Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. | 
| 
        
        
        static
        
        
        void | 
      setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, int[] presetSizes, int unit)
      Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. | 
| 
        
        
        static
        
        
        void | 
      setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType)
      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. | 
| 
        
        
        static
        
        
        void | 
      setCompoundDrawablesRelative(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom)
      Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. | 
| 
        
        
        static
        
        
        void | 
      setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom)
      Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. | 
| 
        
        
        static
        
        
        void | 
      setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, int start, int top, int end, int bottom)
      Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. | 
| 
        
        
        static
        
        
        void | 
      setCustomSelectionActionModeCallback(TextView textView, ActionMode.Callback callback)
      Sets a selection action mode callback on a TextView. | 
| 
        
        
        static
        
        
        void | 
      setTextAppearance(TextView textView, int resId)
      Sets the text appearance from the specified style resource. | 
| Inherited methods | |
|---|---|
|  From
class 
  
    java.lang.Object
  
 | |
Constants
AUTO_SIZE_TEXT_TYPE_NONE
int AUTO_SIZE_TEXT_TYPE_NONE
The TextView does not auto-size text (default).
Constant Value: 0 (0x00000000)
AUTO_SIZE_TEXT_TYPE_UNIFORM
int AUTO_SIZE_TEXT_TYPE_UNIFORM
The TextView scales text size both horizontally and vertically to fit within the container.
Constant Value: 1 (0x00000001)
Public methods
getAutoSizeMaxTextSize
int getAutoSizeMaxTextSize (TextView textView)
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| 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
int getAutoSizeMinTextSize (TextView textView)
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| 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
int getAutoSizeStepGranularity (TextView textView)
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| int | the current auto-size step granularity in pixels. | 
getAutoSizeTextAvailableSizes
int[] getAutoSizeTextAvailableSizes (TextView textView)
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| int[] | the current auto-size intsizes array (in pixels). | 
getAutoSizeTextType
int getAutoSizeTextType (TextView textView)
Returns the type of auto-size set for this widget.
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| int | an intcorresponding to one of the auto-size types:AUTO_SIZE_TEXT_TYPE_NONEorAUTO_SIZE_TEXT_TYPE_UNIFORM | 
getCompoundDrawablesRelative
Drawable[] getCompoundDrawablesRelative (TextView textView)
Returns drawables for the start, top, end, and bottom borders from the given text view.
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| Drawable[] | |
getMaxLines
int getMaxLines (TextView textView)
Returns the maximum number of lines displayed in the given TextView, or -1 if the maximum height was set in pixels instead.
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| int | |
getMinLines
int getMinLines (TextView textView)
Returns the minimum number of lines displayed in the given TextView, or -1 if the minimum height was set in pixels instead.
| Parameters | |
|---|---|
| textView | TextView | 
| Returns | |
|---|---|
| int | |
setAutoSizeTextTypeUniformWithConfiguration
void setAutoSizeTextTypeUniformWithConfiguration (TextView textView, int autoSizeMinTextSize, int autoSizeMaxTextSize, int autoSizeStepGranularity, 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 | |
|---|---|
| textView | TextView | 
| 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. SeeTypedValuefor the
             possible dimension units | 
| Throws | |
|---|---|
| IllegalArgumentException | if any of the configuration params are invalid. | 
setAutoSizeTextTypeUniformWithPresetSizes
void setAutoSizeTextTypeUniformWithPresetSizes (TextView textView, int[] presetSizes, 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 | |
|---|---|
| textView | TextView | 
| presetSizes | int: anintarray of sizes in pixels | 
| unit | int: the desired dimension unit for the preset sizes above. SeeTypedValuefor
             the possible dimension units | 
| Throws | |
|---|---|
| IllegalArgumentException | if all of the presetSizesare invalid.
_ | 
setAutoSizeTextTypeWithDefaults
void setAutoSizeTextTypeWithDefaults (TextView textView, int autoSizeTextType)
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.
| Parameters | |
|---|---|
| textView | TextView | 
| autoSizeTextType | int: the type of auto-size. Must be one ofAUTO_SIZE_TEXT_TYPE_NONEorAUTO_SIZE_TEXT_TYPE_UNIFORM | 
setCompoundDrawablesRelative
void setCompoundDrawablesRelative (TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom)
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 setBounds(Rect)
 called.
 
setCompoundDrawables(Drawable, Drawable, Drawable, Drawable) or related methods.
    | Parameters | |
|---|---|
| textView | TextView: The TextView against which to invoke the method. | 
| start | Drawable | 
| top | Drawable | 
| end | Drawable | 
| bottom | Drawable | 
setCompoundDrawablesRelativeWithIntrinsicBounds
void setCompoundDrawablesRelativeWithIntrinsicBounds (TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom)
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.
 
setCompoundDrawables(Drawable, Drawable, Drawable, Drawable) or related methods.
    | Parameters | |
|---|---|
| textView | TextView: The TextView against which to invoke the method. | 
| start | Drawable | 
| top | Drawable | 
| end | Drawable | 
| bottom | Drawable | 
setCompoundDrawablesRelativeWithIntrinsicBounds
void setCompoundDrawablesRelativeWithIntrinsicBounds (TextView textView, int start, int top, int end, int bottom)
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 usingsetCompoundDrawables(Drawable, Drawable, Drawable, Drawable) or related methods.
    | Parameters | |
|---|---|
| textView | TextView: The TextView against which to invoke the method. | 
| 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. | 
setCustomSelectionActionModeCallback
void setCustomSelectionActionModeCallback (TextView textView, ActionMode.Callback callback)
Sets a selection action mode callback on a TextView.
 Also this method can be used to fix a bug in framework SDK 26. On these affected devices,
 the bug causes the menu containing the options for handling ACTION_PROCESS_TEXT after text
 selection to miss a number of items. This method can be used to fix this wrong behaviour for
 a text view, by passing any custom callback implementation. If no custom callback is desired,
 a no-op implementation should be provided.
 Note that, by default, the bug will only be fixed when the default floating toolbar menu
 implementation is used. If a custom implementation of Menu is provided, this should
 provide the method Menu#removeItemAt(int) which removes a menu item by its position,
 as given by Menu#getItem(int). Also, the following post condition should hold: a call
 to removeItemAt(i), should not modify the results of getItem(j) for any j < i. Intuitively,
 removing an element from the menu should behave as removing an element from a list.
 Note that this method does not exist in the Menu interface. However, it is required,
 and going to be called by reflection, in order to display the correct process text items in
 the menu.
| Parameters | |
|---|---|
| textView | TextView: The TextView to set the action selection mode callback on. | 
| callback | ActionMode.Callback: The action selection mode callback to set on textView. | 
setTextAppearance
void setTextAppearance (TextView textView, int resId)
Sets the text appearance from the specified style resource.
 Use a framework-defined TextAppearance style like
 @android:style/TextAppearance.Material.Body1.
| Parameters | |
|---|---|
| textView | TextView: The TextView against which to invoke the method. | 
| resId | int: The resource identifier of the style to apply. | 
- Interfaces
- Classes- AutoScrollHelper
- CircularProgressDrawable
- CompoundButtonCompat
- ContentLoadingProgressBar
- CursorAdapter
- DrawerLayout
- DrawerLayout.LayoutParams
- DrawerLayout.SavedState
- DrawerLayout.SimpleDrawerListener
- EdgeEffectCompat
- ExploreByTouchHelper
- ImageViewCompat
- ListPopupWindowCompat
- ListViewAutoScrollHelper
- ListViewCompat
- NestedScrollView
- PopupMenuCompat
- PopupWindowCompat
- ResourceCursorAdapter
- ScrollerCompat
- SimpleCursorAdapter
- SlidingPaneLayout
- SlidingPaneLayout.LayoutParams
- SlidingPaneLayout.SimplePanelSlideListener
- Space
- SwipeRefreshLayout
- TextViewCompat
- ViewDragHelper
- ViewDragHelper.Callback
 
