Most visited

Recently visited

TextViewCompat

public final class TextViewCompat
extends Object

java.lang.Object
   ↳ android.support.v4.widget.TextViewCompat


Helper for accessing features in TextView introduced after API level 4 in a backwards compatible fashion.

Summary

Public methods

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 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 setTextAppearance(TextView textView, int resId)

Sets the text appearance from the specified style resource.

Inherited methods

From class java.lang.Object

Public methods

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

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.

Calling this method will overwrite any Drawables previously set using 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.

Calling this method will overwrite any Drawables previously set using 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 using setCompoundDrawables(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.

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 or see TextAppearance for the set of attributes that can be used in a custom style.

Parameters
textView TextView: The TextView against which to invoke the method.
resId int: The resource identifier of the style to apply.

Hooray!