List of usage examples for android.text SpannableString length
int length();
From source file:Main.java
public static LruCache<String, SpannableString> getInSize(int size) { return new LruCache<String, SpannableString>(size) { @Override//from w w w . j a va2s.com protected int sizeOf(String key, SpannableString value) { return value.length(); } @Override protected SpannableString create(String key) { return null; } }; }
From source file:Main.java
public static SpannableString bold(SpannableString sequence) { sequence.setSpan(new StyleSpan(Typeface.BOLD), 0, sequence.length(), 0); return sequence; }
From source file:Main.java
/** * //from www .ja va2 s . com * * @param text * @return */ public static SpannableString strickout(String text) { SpannableString ss = new SpannableString(text); ss.setSpan(new StrikethroughSpan(), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return ss; }
From source file:Main.java
public static SpannableString centerText(SpannableString sequence) { sequence.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, sequence.length(), 0); return sequence; }
From source file:Main.java
public static Spannable createUnderline(String str) { SpannableString contentUnderline = new SpannableString(str); contentUnderline.setSpan(new UnderlineSpan(), 0, contentUnderline.length(), 0); return contentUnderline; }
From source file:Main.java
public static CharSequence getBoldedString(String value) { SpannableString spanned = new SpannableString(value); spanned.setSpan(new StyleSpan(Typeface.BOLD), 0, spanned.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spanned; }
From source file:Main.java
public static SpannableString backgroundColor(SpannableString sequence, List<String> color) { int hex = Color.parseColor(color.get(0)); sequence.setSpan(new BackgroundColorSpan(hex), 0, sequence.length(), 0); return sequence; }
From source file:com.android.talkback.menurules.RuleSpannables.java
/** * Retrieves SpannableString in the accessibility node. The content description and text of the * node is checked in order./*from w w w .java2 s . c om*/ * @param node * @return SpannableString with at least 1 UrlSpan. null if no UrlSpan found in the node. */ private static SpannableString getStringWithUrlSpan(AccessibilityNodeInfoCompat node) { CharSequence text = node.getContentDescription(); if (!TextUtils.isEmpty(text)) { if (!(text instanceof SpannableString)) { return null; } } else { text = node.getText(); if (TextUtils.isEmpty(text) || !(text instanceof SpannableString)) { return null; } } SpannableString spannable = (SpannableString) text; final URLSpan[] urlSpans = spannable.getSpans(0, spannable.length(), URLSpan.class); if (urlSpans == null || urlSpans.length == 0) { return null; } return spannable; }
From source file:fr.simon.marquis.secretcodes.util.Utils.java
public static SpannableString applyCustomTypeFace(CharSequence src, Context ctx) { SpannableString span = new SpannableString(src); span.setSpan(//ww w. j av a2 s .co m new CustomTypefaceSpan("", RobotoTypefaceManager.obtaintTypeface(ctx, RobotoTypefaceManager.ROBOTOSLAB_REGULAR)), 0, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return span; }
From source file:org.transdroid.core.gui.navigation.NavigationHelper.java
/** * Converts a string into a {@link Spannable} that displays the string in the Roboto Condensed font * @param string A plain text {@link String} * @return A {@link Spannable} that can be applied to supporting views (such as the action bar title) so that the input string will be displayed * using the Roboto Condensed font (if the OS has this) *///w w w . j a v a 2 s . c om public static SpannableString buildCondensedFontString(String string) { if (string == null) { return null; } SpannableString s = new SpannableString(string); s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return s; }