Most visited

Recently visited

TextViewCompat

public final class TextViewCompat
extends Object

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


Helper用于访问以向后兼容的方式在API级别4之后引入的 TextView功能。

Summary

Public methods

static int getMaxLines(TextView textView)

返回给定TextView中显示的最大行数,如果最大高度设置为像素,则返回-1。

static int getMinLines(TextView textView)

返回给定TextView中显示的最小行数,如果最小高度设置为像素,则返回-1。

static void setCompoundDrawablesRelative(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom)

设置Drawable(如果有的话)出现在文本的开头,上方,结尾和下方。

static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom)

设置Drawable(如果有的话)出现在文本的开头,上方,结尾和下方。

static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, int start, int top, int end, int bottom)

设置Drawable(如果有的话)出现在文本的开头,上方,结尾和下方。

static void setTextAppearance(TextView textView, int resId)

从指定的样式资源中设置文本外观。

Inherited methods

From class java.lang.Object

Public methods

getMaxLines

int getMaxLines (TextView textView)

返回给定TextView中显示的最大行数,如果最大高度设置为像素,则返回-1。

Parameters
textView TextView
Returns
int

getMinLines

int getMinLines (TextView textView)

返回给定TextView中显示的最小行数,如果最小高度设置为像素,则返回-1。

Parameters
textView TextView
Returns
int

setCompoundDrawablesRelative

void setCompoundDrawablesRelative (TextView textView, 
                Drawable start, 
                Drawable top, 
                Drawable end, 
                Drawable bottom)

设置Drawable(如果有的话)出现在文本的开头,上方,结尾和下方。 如果您不想在此处绘制Drawable,请使用null Drawables必须已经调用了setBounds(Rect)

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)

设置Drawable(如果有的话)出现在文本的开头,上方,结尾和下方。 如果您不想在此处绘制Drawable,请使用null Drawables的边界将被设置为它们的内在边界。

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)

从指定的样式资源中设置文本外观。

使用框架定义的 TextAppearance样式,如 @android:style/TextAppearance.Material.Body1或参见 TextAppearance以获取可在自定义样式中使用的属性集。

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

Hooray!