Created
May 3, 2017 15:16
-
-
Save v3n3/b98b4a6f6cdc9b99c6cb38a09b42e6d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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