Skip to content

Instantly share code, notes, and snippets.

@v3n3
Created May 3, 2017 15:16
Show Gist options
  • Select an option

  • Save v3n3/b98b4a6f6cdc9b99c6cb38a09b42e6d8 to your computer and use it in GitHub Desktop.

Select an option

Save v3n3/b98b4a6f6cdc9b99c6cb38a09b42e6d8 to your computer and use it in GitHub Desktop.
/**
* Underline a portion of the text.
*
* @param view The TextView containing the text to underline.
* @param spanSize an array that contain the start index and the end index.
*/
@android.databinding.BindingAdapter("underline")
public static void underlineText(TextView view, @NonNull int[] spanSize) {
if (view != null && spanSize.length == 2) {
SpannableString content = new SpannableString(view.getText());
content.setSpan(new UnderlineSpan(), spanSize[0], spanSize[1], 0);
view.setText(content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment