You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the default schemes; `ColorScheme`, `StyleScheme`, `LinkScheme` and `OnClickScheme`, or implement the `Scheme` interface to create a custom scheme.
52
+
Use the default schemes; `ColorScheme`, `OnBackgroundScheme`, `StyleScheme`, `FontScheme`, `LinkScheme` and `OnClickScheme`, or implement the `Scheme` interface to create a custom scheme.
59
53
60
54
```java
61
55
...
62
56
63
57
highlight.addScheme(
64
-
//modify the style
65
58
newStyleScheme(
66
59
Pattern.compile("Highlight"),
67
60
StyleScheme.STYLE.BOLD_ITALIC
61
+
).addScopeScheme(
62
+
//scheme in scope of other schemes
63
+
newColorScheme(
64
+
Pattern.compile("light"),
65
+
Color.parseColor("#FF03DAC5")
66
+
)
68
67
)
69
68
);
70
69
71
70
highlight.addScheme(
72
-
//modify the text color
73
-
newColorScheme(
74
-
Pattern.compile("light"),
75
-
Color.parseColor("#FF03DAC5")
76
-
)
77
-
);
78
-
79
-
highlight.addScheme(
80
-
//make the links clickable
71
+
//clickable links
81
72
newLinkScheme().setPainTextUnderline(false)
82
73
);
83
74
84
75
highlight.addScheme(
85
-
//make a clickable text
76
+
//clickable text
86
77
newOnClickScheme(
87
78
Pattern.compile("Highlight"),
88
79
newOnClickScheme.OnClickListener() {
@@ -95,30 +86,50 @@ highlight.addScheme(
95
86
);
96
87
97
88
highlight.addScheme(
98
-
//create the custom scheme
99
-
newScheme() {
100
-
@Override
101
-
publicPatterngetRegex() {
102
-
returnPattern.compile("Highlight");
103
-
}
104
-
105
-
@Override
106
-
publicObjectgetSpan(@NonNullCharSequencetext) {
107
-
returnnewBackgroundColorSpan(Color.GRAY);
108
-
}
109
-
110
-
@Override
111
-
publicbooleangetClearOldSpan() {
112
-
returnfalse;
113
-
}
114
-
});
115
-
116
-
//for the library to know how to remove span
117
-
highlight.addSpanType(BackgroundColorSpan.class);
89
+
newColorScheme(
90
+
Pattern.compile("Project"),
91
+
Color.BLACK
92
+
).addScopeScheme(
93
+
//font scheme
94
+
newFontScheme(
95
+
FontScheme.getFont(this, R.font.pacifico_regular)
96
+
)
97
+
)
98
+
);
99
+
118
100
...
119
101
```
120
102
121
-
## Performance
103
+
## SchemeScope
104
+
105
+
Every schema has a scope to which other schemas can be added via the `addScopeScheme (...)` method. Schemes added to a scope will run only within that scope, saving processing and creating possibilities for smarter highlights.
0 commit comments