EmphasisTextView: 支持部分文字高亮的TextView

jopen 8年前發布 | 16K 次閱讀 Android開發 移動開發 EmphasisTextView

EmphasisTextView

EmphasisTextView - 一個Android textview支持部分文字或全部文字高亮。

Screenshots

Demo Screenshot

How to

To set the highlight areas you can add the following statements programmatically:

emphasisTextView.setText("SALAD");
emphasisTextView.setTextToHighlight("sa");
emphasisTextView.setHighlightColor("#ff3393b4"); 
emphasisTextView.setCaseInsensitive(true);
emphasisTextView.highlight();

Please check the sample project for some more working examples.

Add it to your project

This library is hosted in jcenter

For gradle, you can import it with:

dependencies {
    compile 'com.athkalia.emphasis:emphasis:0.3'
}

For maven, you can import it with:

<dependency>
    <groupId>com.athkalia.emphasis</groupId>
    <artifactId>emphasis</artifactId>
    <type>aar</type>
    <version>0.3</version>
</dependency>

Todos

Feel free to open a pull request for anything that you want to see added.

What I have in mind:

1) Introduce a delegate when someone is using another class that is already extending from TextView (possibly another library).

2) Create similar functionality via xml attributes.

項目地址: https://github.com/athkalia/EmphasisTextView

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!