@@ -54,8 +54,73 @@ highlightTextWatcher.addScheme(
5454// add the listener
5555binding. edittext. addTextChangedListener(highlightTextWatcher);
5656```
57- ## Add to project
57+ ## Schemes
58+ Use the default schemes; ` ColorScheme ` , ` StyleScheme ` , ` LinkScheme ` and ` OnClickScheme ` , or implement the ` Scheme ` interface to create a custom scheme.
59+
60+ ``` java
61+ ...
5862
63+ highlight. addScheme(
64+ // modify the style
65+ new StyleScheme (
66+ Pattern . compile(" Highlight" ),
67+ StyleScheme . STYLE. BOLD_ITALIC
68+ )
69+ );
70+
71+ highlight. addScheme(
72+ // modify the text color
73+ new ColorScheme (
74+ Pattern . compile(" light" ),
75+ Color . parseColor(" #FF03DAC5" )
76+ )
77+ );
78+
79+ highlight. addScheme(
80+ // make the links clickable
81+ new LinkScheme (). setPainTextUnderline(false )
82+ );
83+
84+ highlight. addScheme(
85+ // make a clickable text
86+ new OnClickScheme (
87+ Pattern . compile(" Highlight" ),
88+ new OnClickScheme .OnClickListener () {
89+ @Override
90+ public void onClick (CharSequence text ) {
91+ goToURL(" https://github.com/Irineu333/Highlight" );
92+ }
93+ }
94+ )
95+ );
96+
97+ highlight. addScheme(
98+ // create the custom scheme
99+ new Scheme () {
100+ @Override
101+ public Pattern getRegex () {
102+ return Pattern . compile(" Highlight" );
103+ }
104+
105+ @Override
106+ public Object getSpan (@NonNull CharSequence text ) {
107+ return new BackgroundColorSpan (Color . GRAY );
108+ }
109+
110+ @Override
111+ public boolean getClearOldSpan () {
112+ return false ;
113+ }
114+ });
115+
116+ // for the library to know how to remove span
117+ highlight. addSpanType(BackgroundColorSpan . class);
118+ ...
119+ ```
120+
121+ ## Performance
122+
123+ ## Add to project
59124
60125Add the jitpack to project in build.gradle or settings.gradle (gradle 7+)
61126``` groovy
0 commit comments