RichTextView
1.0.0
來自馬文
< dependency >
< groupId >com.github.st235</ groupId >
< artifactId >richtextview</ artifactId >
< version >0.0.3</ version >
< type >pom</ type >
</ dependency >來自Gradle
implementation 'com.github.st235:richtextview:0.0.3'
首先,必須初始化庫。如果省略了此步驟,則嘗試使用的嘗試將產生異常。
public class App extends Application {
@ Override
public void onCreate () {
super . onCreate ();
FontProvider . init ( getAssets ());
}
}從標記中輕鬆查看可配置,
< st235 .github.com.richtextview.RichTextView
android : layout_width = " match_parent "
android : layout_height = " match_parent "
android : gravity = " center "
android : text = " No more  "
android : textSize = " 22sp "
app : fontAsset = " fontawesome-webfont.ttf " />但是,如果您需要從資產中手動下載字體,那麼並非所有內容都丟失了!
/**
* loads the font in the specified path relative to the assets folder.
* @param fontAsset - font link
*/
public void loadFont ( @ Nullable String fontAsset )另外,您可以使用跨度顯示使用CustomFontSpan的自定義字體。
final TextView footer = ...;
SpannableString footerText = new SpannableString ( " uf0e7 Font Awesome (http://fontawesome.io/)" );
footerText . setSpan ( new CustomFontSpan ( "" , "fontawesome-webfont.ttf" ), 0 , 1 , Spanned . SPAN_EXCLUSIVE_EXCLUSIVE );
footer . setText ( footerText );麻省理工學院許可證
版權(C)2018 Alexander Dadukin
特此免費授予獲得此軟件副本和相關文檔文件副本(“軟件”)的任何人,以無限制處理該軟件,包括無限制的使用權,複製,複製,修改,合併,合併,發布,分發,分發,分發,訂婚,和/或允許軟件的副本,並允許對以下條件提供以下條件,以下是以下條件。
上述版權通知和此許可通知應包含在軟件的所有副本或大量部分中。
該軟件是“原樣”提供的,沒有任何形式的明示或暗示保證,包括但不限於適銷性,特定目的的適用性和非侵權的保證。在任何情況下,作者或版權持有人都不應對任何索賠,損害賠償或其他責任責任,無論是在合同,侵權的訴訟中還是其他責任,是由軟件,使用或與軟件中的使用或其他交易有關的。