點(diǎn)擊可選中單個(gè)單詞的TextView,提供多選和其他自定義選項(xiàng)
項(xiàng)目地址:SelectableTextViewProject
效果圖:
2.gif
2.gif
功能如效果圖所示,另外提供多選復(fù)制的選項(xiàng),沒有對TextView進(jìn)行過多自定義,更像是一個(gè)封裝,因此使用方式按照TextView來使用即可
提供的方法列表:
方法 | xml屬性 | 方法描述 |
---|---|---|
void setEnableMultSelect(boolean enableMultSelect) |
`` | 是否允許多選 |
void setEnableSingleSelect(boolean enableSingleSelect) |
`` | 是否允許單選 |
void setSelectTextFrontColor(int selectTextFrontColor) |
'' | 設(shè)置選中單詞的字體顏色(傳入color值) |
void setSelectTextFrontColorRes(int selectTextFrontColor) |
`` | 設(shè)置選中單詞的字體顏色(傳入Res資源) |
void setSelectTextBackColor(int selectTextBackColor) |
'' | 設(shè)置選中單詞的背景顏色(傳入color值) |
void setSelectTextBackColorRes(int selectTextBackColor) |
`` | 設(shè)置選中單詞的背景顏色(傳入Res資源) |
void setOnWordClickListener(OnWordClickListener onWordClickListener) |
`` | 設(shè)置選中單詞的響應(yīng)事件 |
dismissSelected() |
`` | 去除選中效果 |
使用方法
1. Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.Brioal:SelectableTextViewProject:1.0'
}