本文將繼續介紹App Resources中的資源類型(Animation、Color State List、String、Style)。
如果需要了解Android中的資源規范,您可以訪問我翻譯的這篇官方文檔:《Android官方文檔之App Resources(上)》。
如需訪問官方原文,您可以點擊這個鏈接:《Resource Types》。
在下1篇文章中(Android官方文檔之App Resources(下)),將介紹App Resources中其余的資源類型(Layout、Menu、Drawable)。
本節將介紹Android中各種資源的類型、格式、語法、和援用方式。
配置預定義的動畫(Define pre-determined animations)。
其中補間動畫(Tween animations)應存儲于res/anim/
目錄下,并通過R.anim
援用;
幀動畫(Frame animations)應存儲于 res/drawable/
目錄下,并通過 R.drawable
援用;
屬性動畫(Object animations)應存儲于res/animator/
目錄下,并通過R.animator
援用。
如需了解有關動畫的介紹,您可以訪問我翻譯的文檔:《Android官方文檔之Animation》
文件目錄:
res/animator/filename.xml
核心類:
ValueAnimator
, ObjectAnimator
, AnimatorSet
。
援用方式:
In Java: R.animator.filename
In XML: @[package:]animator/filename
語法:
<set
android:ordering=["together" | "sequentially"]>
<objectAnimator
android:propertyName="string"
android:duration="int"
android:valueFrom="float | int | color"
android:valueTo="float | int | color"
android:startOffset="int"
android:repeatCount="int"
android:repeatMode=["repeat" | "reverse"]
android:valueType=["intType" | "floatType"]/>
<animator
android:duration="int"
android:valueFrom="float | int | color"
android:valueTo="float | int | color"
android:startOffset="int"
android:repeatCount="int"
android:repeatMode=["repeat" | "reverse"]
android:valueType=["intType" | "floatType"]/>
<set>
...
</set>
</set>
根標簽必須為<set>, <objectAnimator>, 或 <valueAnimator>之1
。
標簽及其屬性:
<set>
:可以包括其他動畫標簽,如<set>, <objectAnimator>, 或 <valueAnimator>
,對應AnimatorSet
類。
android:ordering
:指定動畫播放順序Value | Description |
---|---|
sequentially |
順序履行 |
together (默許) |
同時履行 |
<objectAnimator>
:指定某個對象的屬性在1定時間內履行的動畫。對應ObjectAnimator
類。
屬性:
– android:propertyName
:String類型,不可缺省。指定View對象的某個屬性,如alpha
、backgroundColor
等。應調用loadAnimator()
或setTarget()
方法,將XML屬性動畫設置到包括了該屬性的對象上。
– android:valueTo
:float, int, 或 color類型,不可缺省。指定動畫的結束值。其中color是1個6位的16進制數,如#333333
。
– android:valueFrom
:float, int, 或 color類型。指定動畫的起始值。若未指定,則將通過屬性的get()
方法獲得起始值。
– android:duration
:int類型。動畫履行的毫秒數,若未指定,則默許為300毫秒。
– android:startOffset
:int類型。調用start()
后延遲的毫秒數。
– android:repeatCount
:int類型。動畫的重復次數。設置為“⑴”表示無窮循環。設置為“0”表示不循環,即只履行1次。設置為“1”表示循環1次,即履行兩次。
– android:repeatMode
:int類型。當動畫履行完后的行動。需配合android:repeatCount
屬性使用(不能為0,可以為正整數或⑴),reverse
表示反向履行。repeat
表示重復履行。
– android:valueType
:intType
或floatType(默許)
。指定動畫屬性值的變化類型。若操作的屬性是色彩,則不能指定該屬性。
<animator>
:在規定的時間內改變某個屬性值。對應ValueAnimator
類。
屬性:
– android:valueTo
:float, int, 或 color 類型,不可缺省。
– android:valueFrom
:float, int, 或 color 類型,不可缺省。
– android:duration
:int類型。缺省值為300毫秒。
– android:startOffset
:int類型。
– android:repeatMode
: int類型。
– android:valueType
:intType
、或floatType(默許)
<!-- res/animator/property_animator.xml -->
<set android:ordering="sequentially">
<set>
<objectAnimator
android:propertyName="x"
android:duration="500"
android:valueTo="400"
android:valueType="intType"/>
<objectAnimator
android:propertyName="y"
android:duration="500"
android:valueTo="300"
android:valueType="intType"/>
</set>
<objectAnimator
android:propertyName="alpha"
android:duration="500"
android:valueTo="1f"/>
</set>
在Java代碼中引入:
AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(myContext,
R.anim.property_animator);
set.setTarget(myObject);
set.start();
文件目錄:
res/anim/filename.xml
核心類:
Animation
援用方式:
In Java: R.anim.filename
In XML: @[package:]anim/filename
語法:
<?xml version="1.0" encoding="utf⑻"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@[package:]anim/interpolator_resource"
android:shareInterpolator=["true" | "false"] >
<alpha
android:fromAlpha="float"
android:toAlpha="float" />
<scale
android:fromXScale="float"
android:toXScale="float"
android:fromYScale="float"
android:toYScale="float"
android:pivotX="float"
android:pivotY="float" />
<translate
android:fromXDelta="float"
android:toXDelta="float"
android:fromYDelta="float"
android:toYDelta="float" />
<rotate
android:fromDegrees="float"
android:toDegrees="float"
android:pivotX="float"
android:pivotY="float" />
<set>
...
</set>
</set>
根標簽必須為<alpha>, <scale>, <translate>, <rotate>, 或<set>之1
。
標簽及其屬性:
<set>
:補間動畫集合。對應AnimationSet
類。
– android:interpolator
:插值器資源。具體含義請參考《Android官方文檔之Animation》中有關interpolator
的介紹。
– android:shareInterpolator
:Boolean類型。若設置為true,表示該標簽中的所有直接子標簽同享1個interpolator
。
<alpha>
:透明度動畫。淡入淡出效果(A fade-in or fade-out animation)。對應AlphaAnimation
類。
– android:fromAlpha
:Float類型。起始透明度。0.0表示完全透明,1.0表示完全不透明。
– android:toAlpha
:Float類型。終止透明度。0.0表示完全透明,1.0表示完全不透明。
<scale>
:縮放動畫。對應ScaleAnimation
類。
– android:fromXScale
:Float類型。x方向的起始縮放比例,若為1.0,表示無縮放。
– android:toXScale
:Float類型。x方向的終究縮放比例。
– android:fromYScale
:Float類型。y方向的起始縮放比例,若為1.0,表示無縮放。
– android:toYScale
:Float類型。y方向的終究縮放比例。
– android:pivotX
:Float類型。x方向的縮放中心。
– android:pivotY
:Float類型。y方向的縮放中心。
<translate>
:平移動畫。對應TranslateAnimation
類。平移的值支持3種格式。1、值從⑴00到100,以%結束,表示相對自己本身平移。2、值從⑴00到100,以%p結束,表示相對父控件平移。3、沒有后綴,只是1個值,表示平移的絕對數值。
– android:fromXDelta
:Float 或百分比類型。x方向的起始平移位置。平移的距離為5dp(5);平移的距離為控件寬度的5%(5%);平移的距離為父控件寬度的5%(5%p)。
– android:toXDelta
:Float 或百分比類型。x方向的終止平移位置。
– android:fromYDelta
:Float 或百分比類型。y方向的起始平移位置。
– android:toYDelta
:Float 或百分比類型。y方向的終止平移位置。
<rotate>
:旋轉動畫。對應RotateAnimation
類。
– android:fromDegrees
:Float類型。旋轉起始角度。
– android:toDegrees
:Float類型。旋轉終止角度。
– android:pivotX
:Float或百分比類型。x坐標旋轉中心。
– android:pivotY
:Float或百分比類型。y坐標旋轉中心。
<!-- res/anim/hyperspace_jump.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="1.0"
android:toXScale="1.4"
android:fromYScale="1.0"
android:toYScale="0.6"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false"
android:duration="700" />
<set
android:interpolator="@android:anim/accelerate_interpolator"
android:startOffset="700">
<scale
android:fromXScale="1.4"
android:toXScale="0.0"
android:fromYScale="0.6"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="400" />
<rotate
android:fromDegrees="0"
android:toDegrees="⑷5"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="400" />
</set>
</set>
引入到代碼中:
ImageView image = (ImageView) findViewById(R.id.image);
Animation hyperspaceJump = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
image.startAnimation(hyperspaceJump);
文件目錄:
res/drawable/filename.xml
核心類:
AnimationDrawable
援用方式:
In Java: R.drawable.filename
In XML: @[package:]drawable.filename
語法:
<?xml version="1.0" encoding="utf⑻"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot=["true" | "false"] >
<item
android:drawable="@[package:]drawable/drawable_resource_name"
android:duration="integer" />
</animation-list>
標簽及屬性:
<animation-list>
:不可缺省,且必須作為根標簽。
– android:oneshot
:boolean類型。若為true表示重復履行。
<item>
:每幀動畫。
– android:drawable
:drawable資源。
– android:duration
:這1幀的展現時間。
<!-- res/anim/rocket.xml -->
<?xml version="1.0" encoding="utf⑻"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>
在Java中引入:
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start();
用于切換控件在不同狀態時的不同色彩的資源文件。
文件位置:
res/color/filename.xml
核心類:
ColorStateList
援用方式:
In Java: R.color.filename
In XML: @[package:]color/filename
語法:
<?xml version="1.0" encoding="utf⑻"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:color="hex_color"
android:state_pressed=["true" | "false"]
android:state_focused=["true" | "false"]
android:state_selected=["true" | "false"]
android:state_checkable=["true" | "false"]
android:state_checked=["true" | "false"]
android:state_enabled=["true" | "false"]
android:state_window_focused=["true" | "false"] />
</selector>
元素及屬性:
<selector>
:不可缺省。必須是根標簽。并包括多個<item>
標簽。
<item>
:定義某個狀態下的色彩。
– android:color
:不可缺省。16進制數。用于指定RGB值及可選的alpha通道:#RGB、#ARGB、#RRGGBB、#AARRGGBB
– android:state_pressed
:boolean類型。表示控件是不是處于被點擊( touched/clicked)狀態。
– android:state_focused
:boolean類型。表示控件是不是處于取得焦點狀態。
– android:state_selected
:boolean類型。表示控件是不是被選中。
– android:state_checkable
:boolean類型。表示控件是不是是可檢勾選的(僅適用于可勾選的控件)。
– android:state_checked
:boolean類型。表示控件是不是處于勾選狀態(僅適用于可勾選的控件)。
– android:state_enabled
:boolean類型。表示控件是不是處于使能狀態(便可以接受 touch/click事件)。
– android:state_window_focused
:boolean類型。表示利用窗口是不是處于具有焦點(利用在前臺)。
舉例:
<!-- res/color/button_text.xml -->
<?xml version="1.0" encoding="utf⑻"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ffff0000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff0000ff"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
在Button中援用該資源:
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button_text"
android:textColor="@color/button_text" />
Style資源用于定義UI的樣式。1個樣式可以作用某個View上,也能夠作用在全部Activity乃至是Application上。如需了解樣式和主題的官方介紹,您可以點擊這個鏈接:《Styles and Themes》。
!請注意:style是1個單獨的資源,如需援用該資源,需要援用的是name
屬性中定義的名字,而不是XML文件的名字。所以,您可以將所有的style資源都定義在1個XML文件中,并將<resources>
標簽作為根標簽。
文件目錄:
res/values/filename.xml
援用方式:
In XML: @[package:]style/style_name
語法:
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<style
name="style_name"
parent="@[package:]style/style_to_inherit">
<item
name="[package:]style_property_name"
>style_value</item>
</style>
</resources>
標簽及其屬性:
<resources>
:不可缺省,且必須是根標簽。無屬性。
<style>
:定義1個樣式,可包括<item>
標簽。
– name
:String類型,不可缺省。樣式的名字。Activity、Application或View所援用的ID就是這個名字。
– parent
:Style 資源。繼承其他style資源。
<item>
:為style定義1個屬性。必須是<style>
的子標簽。
– name
:屬性資源,不可缺省。用于定義某個屬性,如android:textColor
。
示例:
<!-- res/values/ -->
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<style name="CustomText" parent="@style/Text">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#008</item>
</style>
</resources>
將上述style利用于TextView上:
<!-- res/layout/ -->
<?xml version="1.0" encoding="utf⑻"?>
<EditText
style="@style/CustomText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World!" />
用于為利用程序提供字符串資源。有以下3種字符串的格式:
String:用于提供1個單獨的字符串;
String Array:用于提供1個字符串數組;
Quantity Strings (Plurals):用于提供復數的字符串(carries different strings for pluralization)。
字符串資源可以被Java程序或XML文件援用。
!請注意:String是1個單獨的資源,如需援用該資源,需要援用的是name
屬性中定義的名字,而不是XML文件的名字。所以,您可以將所有的String資源都定義在1個XML文件中,并將<resources>
標簽作為根標簽。
文件目錄:
res/values/filename.xml
援用方式:
In Java: R.string.string_name
In XML:@string/string_name
語法:
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<string
name="string_name">text_string</string>
</resources>
標簽及其屬性:
<resources>
:不可缺省,必須為根標簽。無屬性。
<string>
:值為您所指定的字符串內容。
– name
:String類型。字符串的鍵。通過ID援用的就是這個鍵。
示例:
<!-- res/values/strings.xml -->
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<string name="hello">Hello!</string>
</resources>
援用上述字符串資源:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
在Java中援用上述資源:
String string = getString(R.string.hello);
1個字符串數組資源,可以在程序中援用。
!請注意:String Array是1個單獨的資源,如需援用該資源,需要援用的是name
屬性中定義的名字,而不是XML文件的名字。所以,您可以將所有的String Array資源都定義在1個XML文件中,并將<resources>
標簽作為根標簽。
文件目錄:
res/values/filename.xml
援用方式:
In Java: R.array.string_array_name
語法:
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<string-array
name="string_array_name">
<item>text_string</item>
</string-array>
</resources>
標簽及其屬性:
<resources>
:不可缺省,且必須是根標簽。無屬性
<string-array>
:定義了1組字符串資源。每個字符串用1個<item>
標簽包括。
– name
:String類型。字符串數組的鍵。程序中的ID就是該鍵。
<item>
:String類型。用于定義1個字符串。必須包括在<string-array>
標簽內。無屬性。
示例:
<!-- res/values/strings.xml -->
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<string-array name="planets_array">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
</string-array>
</resources>
在代碼中援用該字符串數組資源:
Resources res = getResources();
String[] planets = res.getStringArray(R.array.planets_array);
不同的語言在單復數上具有不同的語法規則。在英語中,1表示單數,如“1 book”,大于1表示復數,如“n books”,這類單復數的的區分在英語中很常見,而其他語言在單復數的處理上與英語的語法又有很大區分(如中文語法沒有明顯體現復數的概念)。為了支持不同語言的單復數規則,Android提供了zero、one、 two、 few、 many、 other
等枚舉值。
Android提供了getQuantityString()
方法來選擇適合的單復數資源。
復數的字符串資源只能用于復數。
!請注意:Quantity Strings是1個單獨的資源,如需援用該資源,需要援用的是name
屬性中定義的名字,而不是XML文件的名字。所以,您可以將所有的Quantity Strings資源都定義在1個XML文件中,并將<resources>
標簽作為根標簽。
文件目錄:
res/values/filename.xml
援用方式:
In Java: R.plurals.plural_name
語法:
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<plurals
name = "plural_name">
<item quantity = ["zero"|"one"|"two"|"few"|"many"|"other"]>text_string</item>
</plurals>
</resources>
標簽及其屬性:
<resources>
:不可缺省,且必須作為根標簽。無屬性。
<plurals>
:1個字符串的集合。該標簽中包括若干個<item>
標簽。
– name
:String類型。援用該資源的鍵。程序ID援用的就是這個鍵。
<item>
:包括1個單數或復數的字符串。值可以援用其他字符串資源。
– quantity
:為以下若干Value值。
Value | Description |
---|---|
zero | 在某種語言中,當末尾數字為0時,需要特殊處理。如阿拉伯語。 |
one | 在某種語言中,當末尾數字為1時,需要特殊處理。如英語和其他大多數語言;在俄語中,除11之外的其他以1結尾的數字,屬于這1類型。 |
two | 在某種語言中,當末尾數字為2時,需要特殊處理。如威爾士語中的2;斯洛文尼亞語中的102。 |
few | 在某種語言中,較小的數字需要特殊處理。如捷克語中的2、3、4;波蘭語中除12、13、14之外,以2、3、4結尾的數字。 |
many | 在某種語言中,較大的數字需要特殊處理。如馬耳他語中以11⑼9結尾的數字。 |
other | 在某種語言中,并沒有明顯的單復數概念。如中文。 |
示例:
<!-- res/values/strings.xml -->
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<plurals name="numberOfSongsAvailable">
<!--
As a developer, you should always supply "one" and "other"
strings. Your translators will know which strings are actually
needed for their language. Always include %d in "one" because
translators will need to use %d for languages where "one"
doesn't mean 1 (as explained above).
-->
<item quantity="one">%d song found.</item>
<item quantity="other">%d songs found.</item>
</plurals>
</resources>
<!-- res/values-pl/strings.xml -->
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<plurals name="numberOfSongsAvailable">
<item quantity="one">Znaleziono %d piosenk?.</item>
<item quantity="few">Znaleziono %d piosenki.</item>
<item quantity="other">Znaleziono %d piosenek.</item>
</plurals>
</resources>
在Java中援用資源:
int count = getNumberOfsongsAvailable();
Resources res = getResources();
String songsFound = res.getQuantityString(R.plurals.numberOfSongsAvailable, count, count);
需要注意的是,如果您援用的XML文件中包括了格式化的字符(如%d),那末需要在getQuantityString()
方法中傳入3個參數。其中第2個參數用于讓系統決定應當選擇哪一個item標簽中的資源,而第3個參數是1個可變數組,用于替換格式化的字符(如%d)。如果您在字符串資源中未指定格式化的字符,那末可以不傳入第3個參數。
如果您的字符串中包括了單引號(’),那末需要在單引號前加1個反斜杠(\),以便在字符串中能正確辨認這個單引號;或直接用雙引號包括全部字符串,以下所示:
<!-- 正確的表示法,在單引號前加1個反斜杠(\) -->
<string name="good_example">This\'ll work</string>
<!-- 正確的表示法,直接用雙引號包括全部字符串 -->
<string name="good_example_2">"This'll also work"</string>
<!-- 毛病的表示法,編譯毛病 -->
<string name="bad_example">This doesn't work</string>
如果您的字符串中包括了雙引號(”),那末需要在雙引號前加1個反斜杠(\),以便在字符串中能正確辨認這個雙引號。但是,用雙引號包括全部字符串的方式不再可行:
<!-- 正確的表示法,在雙引號前加1個反斜杠(\) -->
<string name="good_example">This is a \"good string\".</string>
<!-- 毛病的表示法,雙引號將被疏忽 -->
<string name="bad_example">This is a "bad string".</string>
<!-- 毛病的表示法,編譯毛病 -->
<string name="bad_example_2">'This is another "bad string".'</string>
通過調用String.format(String, Object...)
方法,可以將字符串進行格式化。如:
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>
上述字符串中,%1$s
表示1個字符串,%2$d
表示1個10進制數。由于format()
方法中的第2個參數是1個可變數組,您可以將參數傳入其中以替換這些轉義字符:
Resources res = getResources();
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);
如:
<?xml version="1.0" encoding="utf⑻"?>
<resources>
<string name="welcome">Welcome to <b>Android</b>!</string>
</resources>
Android支持的HTML標簽包括:
<b>
表示文本加粗;
<i>
表示斜體;
<u>
表示添加下劃線。
為了使HTML標簽生效,需要使用轉義的HTML字符:
<resources>
<string name="welcome_messages">Hello, %1$s! You have <b>%2$d new messages</b>.</string>
</resources>
其中,左尖括號(”<
“)被替換為HTML轉移字符串(”<
“)。
接著調用fromHtml(String)
方法,使HTML標簽生效。
Resources res = getResources();
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);
CharSequence styledText = Html.fromHtml(text);
調用htmlEncode()
方法確保傳入的字符串參數已被轉義,由于只有被轉義后的字符串才能使HTML標簽生效:
String escapedUsername = TextUtil.htmlEncode(username);
Resources res = getResources();
String text = String.format(res.getString(R.string.welcome_messages), escapedUsername, mailCount);
CharSequence styledText = Html.fromHtml(text);
Spannables可以將若干不一樣式(如色彩、字號)的文本對象拼接在1起:
/**
* Returns a CharSequence that concatenates the specified array of CharSequence
* objects and then applies a list of zero or more tags to the entire range.
*
* @param content an array of character sequences to apply a style to
* @param tags the styled span objects to apply to the content
* such as android.text.style.StyleSpan
*
*/
private static CharSequence apply(CharSequence[] content, Object... tags) {
SpannableStringBuilder text = new SpannableStringBuilder();
openTags(text, tags);
for (CharSequence item : content) {
text.append(item);
}
closeTags(text, tags);
return text;
}
/**
* Iterates over an array of tags and applies them to the beginning of the specified
* Spannable object so that future text appended to the text will have the styling
* applied to it. Do not call this method directly.
*/
private static void openTags(Spannable text, Object[] tags) {
for (Object tag : tags) {
text.setSpan(tag, 0, 0, Spannable.SPAN_MARK_MARK);
}
}
/**
* "Closes" the specified tags on a Spannable by updating the spans to be
* endpoint-exclusive so that future text appended to the end will not take
* on the same styling. Do not call this method directly.
*/
private static void closeTags(Spannable text, Object[] tags) {
int len = text.length();
for (Object tag : tags) {
if (len > 0) {
text.setSpan(tag, 0, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
text.removeSpan(tag);
}
}
}
/**
* Returns a CharSequence that applies boldface to the concatenation
* of the specified CharSequence objects.
*/
public static CharSequence bold(CharSequence... content) {
return apply(content, new StyleSpan(Typeface.BOLD));
}
/**
* Returns a CharSequence that applies italics to the concatenation
* of the specified CharSequence objects.
*/
public static CharSequence italic(CharSequence... content) {
return apply(content, new StyleSpan(Typeface.ITALIC));
}
/**
* Returns a CharSequence that applies a foreground color to the
* concatenation of the specified CharSequence objects.
*/
public static CharSequence color(int color, CharSequence... content) {
return apply(content, new ForegroundColorSpan(color));
}