Skip to content

Instantly share code, notes, and snippets.

@Bahaaib
Created August 29, 2017 22:47
Show Gist options
  • Select an option

  • Save Bahaaib/6d132d7fdf752b1c2b9f1d324c68b18b to your computer and use it in GitHub Desktop.

Select an option

Save Bahaaib/6d132d7fdf752b1c2b9f1d324c68b18b to your computer and use it in GitHub Desktop.
Custom spannable String builder to overcome any kind of properties of texts (color, size, etc..) built in java
private SpannableStringBuilder customErrorText(String msg){
int eColor = Color.parseColor("#000000"); // whatever color you want
ForegroundColorSpan fgcspan = new ForegroundColorSpan(eColor);
SpannableStringBuilder textBuilder = new SpannableStringBuilder(msg);
textBuilder.setSpan(fgcspan, 0, msg.length(), 0);
return textBuilder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment