android富文本(SpannableString封裝)


github地址:https://github.com/long8313002/EasyRichText

 

使用指南

 

項目build.gradle

implementation 'com.zhangzheng.easyrichtext:library:1.0.1'

 

布局xml文件

 

顯示效果

 

 

 

支持屬性

分類

屬性名稱

說明

示例

基本屬性

textColor

文字顏色

<TextView

android:id="@+id/tvClick"

android:text="1111111"

android:textColor="#FF0000"

android:textSize="18sp"

android:background="#FFFF00"

android:textStyle="bold|italic"

app:layout_isUnderline="true"

app:layout_isStrikethrough="true"

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

 

text

文字

textSize

文字大小

background

背景

textStyle

類型:

粗:bold

斜:italic

粗斜:bold|italic

isUnderline

下滑線

isStrikethrough

刪除線

 

圖片屬性

src

圖片

<ImageView

android:id="@+id/ivClick"

android:layout_width="30dp"

android:src="@mipmap/ic_launcher"

android:layout_height="30dp"/>

 

width

圖片寬

height

圖片高

 

自定義布局

所有View屬性

性能會有一定影響,可以使用基本屬性的建議使用基本屬性

<FrameLayout

android:id="@+id/flClick"

android:layout_width="wrap_content"

android:padding="10dp"

android:background="#33FF0000"

android:layout_height="wrap_content">

<TextView

android:layout_gravity="center"

android:layout_width="wrap_content"

android:text="我是自定義視圖"

android:layout_height="wrap_content"/>

</FrameLayout>

 

 

 

支持事件

 

 

點擊事件

 

 

 

改變文本

 

 

改變顯示狀態

 

 

 

改變其他屬性

上面表格列舉的屬性,可以直接代碼進行更改,因為控件實際上並沒有添加到窗口上,這里沒辦法直接感知到屬性的變化,所以需要手動調用下update方法。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM