android.text.style.TextAppearanceSpan Java Examples
The following examples show how to use
android.text.style.TextAppearanceSpan.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContactsAdapter.java From tindroid with Apache License 2.0 | 6 votes |
ContactsAdapter(Context context, ImageLoader imageLoader, ClickListener clickListener) { mClickListener = clickListener; mImageLoader = imageLoader; mSelected = new HashMap<>(); setHasStableIds(true); mCursor = null; // Loads a string containing the English alphabet. To fully localize the app, provide a // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file, // define a string with android:name="alphabet" and contents set to all of the // alphabetic characters in the language in their proper sort order, in upper case if // applicable. final String alphabet = context.getString(R.string.alphabet); // Instantiates a new AlphabetIndexer bound to the column used to sort contact names. // The cursor is left null, because it has not yet been retrieved. mAlphabetIndexer = new AlphabetIndexer(null, ContactsLoaderCallback.ContactsQuery.SORT_KEY, alphabet); // Defines a span for highlighting the part of a display name that matches the search // string mHighlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHighlight); }
Example #2
Source File: ProfileManagerActivity.java From Maying with Apache License 2.0 | 6 votes |
public void updateText(long txTotal, long rxTotal, long elapsedInput, long tcpdelayInput) { final SpannableStringBuilder builder = new SpannableStringBuilder(); long tx = item.tx + txTotal; long rx = item.rx + rxTotal; long elapsed = item.elapsed; long tcpdelay = item.tcpdelay; if (elapsedInput != -1) { elapsed = elapsedInput; } if (tcpdelayInput!= -1) { tcpdelay = tcpdelayInput; } builder.append(item.name); if (tx != 0 || rx != 0 || elapsed != 0 || item.url_group != "") { int start = builder.length(); builder.append(getString(R.string.stat_profiles, TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx), String.valueOf(tcpdelay),String.valueOf(elapsed))); builder.setSpan(new TextAppearanceSpan(ProfileManagerActivity.this, android.R.style.TextAppearance_Small), start + 1, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(() -> text.setText(builder)); }
Example #3
Source File: ProfileManagerActivity.java From Maying with Apache License 2.0 | 6 votes |
public void updateText(boolean isShowUrl) { final SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(this.item.url_group).append("\n"); if (isShowUrl) { int start = builder.length(); builder.append(this.item.url); builder.setSpan(new TextAppearanceSpan(ProfileManagerActivity.this, android.R.style.TextAppearance_Small), start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { @Override public void run() { text.setText(builder); } }); }
Example #4
Source File: ProfileManagerActivity.java From ShadowsocksRR with Apache License 2.0 | 6 votes |
public void updateText(boolean isShowUrl) { final SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(this.item.url_group).append("\n"); if (isShowUrl) { int start = builder.length(); builder.append(this.item.url); builder.setSpan(new TextAppearanceSpan(ProfileManagerActivity.this, android.R.style.TextAppearance_Small), start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { @Override public void run() { text.setText(builder); } }); }
Example #5
Source File: ProfileManagerActivity.java From ShadowsocksRR with Apache License 2.0 | 6 votes |
public void updateText(long txTotal, long rxTotal, long elapsedInput) { final SpannableStringBuilder builder = new SpannableStringBuilder(); long tx = item.tx + txTotal; long rx = item.rx + rxTotal; long elapsed = item.elapsed; if (elapsedInput != -1) { elapsed = elapsedInput; } builder.append(item.name); if (tx != 0 || rx != 0 || elapsed != 0 || item.url_group != "") { int start = builder.length(); builder.append(getString(R.string.stat_profiles, TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx), String.valueOf(elapsed), item.url_group)); builder.setSpan(new TextAppearanceSpan(ProfileManagerActivity.this, android.R.style.TextAppearance_Small), start + 1, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { @Override public void run() { text.setText(builder); } }); }
Example #6
Source File: MultiContactPickerAdapter.java From MultiContactPicker with Apache License 2.0 | 6 votes |
private void highlightTerm(TextView tv, String query, String originalString){ if (query != null && !query.isEmpty()) { int startPos = originalString.toLowerCase().indexOf(query.toLowerCase()); int endPos = startPos + query.length(); if (startPos != -1) { Spannable spannable = new SpannableString(originalString); ColorStateList blackColor = new ColorStateList(new int[][]{new int[]{}}, new int[]{Color.BLACK}); TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, blackColor, null); spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(spannable); } else { tv.setText(originalString); } } else { tv.setText(originalString); } }
Example #7
Source File: FindSearchAdapter.java From myapplication with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(FindSearchAdapter.ItemHolder holder, int position) { // String typeAndWhoStr = "<font color=\"#666666\"> ( " // + mDatas.get(position).getType() // + " via." + mDatas.get(position).getWho() + ") </font>"; int textColor = Color.parseColor("#4d000000"); String textStr = mDatas.get(position).getDesc() + " (" + " via. " + mDatas.get(position).getWho() + ")"; SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(textStr); // spannableStringBuilder.setSpan(new ForegroundColorSpan(textColor), // textStr.lastIndexOf("("), textStr.lastIndexOf(")") + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); spannableStringBuilder.setSpan(new TextAppearanceSpan(context, R.style.text_span_style), textStr.lastIndexOf("("), textStr.lastIndexOf(")") + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); holder.searchResultContentTv.setText(spannableStringBuilder); // holder.searchResultContentTv.setText(mDatas.get(position).getDesc() + " (" // + mDatas.get(position).getType() // + " via." + mDatas.get(position).getWho() + ")"); // 将数据保存在itemView的Tag中,以便点击时进行获取 holder.itemView.setTag(mDatas.get(position)); }
Example #8
Source File: QuickConversationAdapter.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
public QuickConversationAdapter(final Context context, List<Message> messageList, EmojiconHandler emojiconHandler) { this.context = context; this.emojiconHandler = emojiconHandler; this.contactService = new AppContactService(context); this.messageDatabaseService = new MessageDatabaseService(context); this.messageList = messageList; conversationUIService = new ConversationUIService((FragmentActivity) context); contactImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { return contactService.downloadContactImage((Activity) context, (Contact) data); } }; contactImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f); contactImageLoader.setImageFadeIn(false); channelImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { return contactService.downloadGroupImage((Activity) context, (Channel) data); } }; channelImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f); channelImageLoader.setImageFadeIn(false); highlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHiglight); }
Example #9
Source File: ChannelFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Instantiates a new Contacts Adapter. * * @param context A context that has access to the app's layout. */ public ChannelAdapter(Context context) { super(context, null, 0); this.context = context; // Stores inflater for use later mInflater = LayoutInflater.from(context); final String alphabet = context.getString(R.string.alphabet); // Instantiates a new AlphabetIndexer bound to the column used to sort contact names. // The cursor is left null, because it has not yet been retrieved. mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet); // Defines a span for highlighting the part of a display name that matches the search // string highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight); }
Example #10
Source File: ContactSelectionFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Instantiates a new Contacts Adapter. * * @param context A context that has access to the app's layout. */ public ContactsAdapter(Context context) { super(context, null, 0); this.context = context; userIdList = new ArrayList<String>(); // Stores inflater for use later mInflater = LayoutInflater.from(context); // Loads a string containing the English alphabet. To fully localize the app, provide a // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file, // define a string with android:name="alphabet" and contents set to all of the // alphabetic characters in the language in their proper sort order, in upper case if // applicable. final String alphabet = context.getString(R.string.alphabet); // Instantiates a new AlphabetIndexer bound to the column used to sort contact names. // The cursor is left null, because it has not yet been retrieved. mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet); // Defines a span for highlighting the part of a display name that matches the search // string highlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHiglight); }
Example #11
Source File: AppContactFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Instantiates a new Contacts Adapter. * * @param context A context that has access to the app's layout. */ public ContactsAdapter(Context context) { super(context, null, 0); this.context = context; // Stores inflater for use later mInflater = LayoutInflater.from(context); // Loads a string containing the English alphabet. To fully localize the app, provide a // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file, // define a string with android:name="alphabet" and contents set to all of the // alphabetic characters in the language in their proper sort order, in upper case if // applicable. final String alphabet = context.getString(R.string.alphabet); // Instantiates a new AlphabetIndexer bound to the column used to sort contact names. // The cursor is left null, because it has not yet been retrieved. mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet); // Defines a span for highlighting the part of a display name that matches the search // string highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight); }
Example #12
Source File: QueryCityActivity.java From WayHoo with Apache License 2.0 | 6 votes |
public CharSequence formatBigMessage(String city) { final TextAppearanceSpan notificationSubjectSpan = new TextAppearanceSpan( this, R.style.NotificationPrimaryText); // Change multiple newlines (with potential white space between), into a // single new line final String message = !TextUtils.isEmpty(city) ? city : ""; String afterStr = "(点击重新定位)"; SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder( message); if (!TextUtils.isEmpty(afterStr)) { spannableStringBuilder.append(afterStr); spannableStringBuilder.setSpan(notificationSubjectSpan, message.length(), message.length() + afterStr.length(), 0); } return spannableStringBuilder; }
Example #13
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textView = (TextView) findViewById(R.id.input); String header = "This is the header"; String description = "This is the description"; Spannable styledText = new SpannableString(header + "\n" + description); TextAppearanceSpan span1 = new TextAppearanceSpan(this, R.style.textHeader); TextAppearanceSpan span2 = new TextAppearanceSpan(this, R.style.textbody); styledText.setSpan(span1, 0, header.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); styledText.setSpan(span2, header.length() + 1, header.length() + 1 + description.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(styledText); }
Example #14
Source File: CountDownView.java From CountDownView with MIT License | 6 votes |
private void init(@Nullable AttributeSet attrs) { textPaint.setColor(Color.BLACK); int textSize; int startDuration; int textAppearanceRef; TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.CountDownView); startDuration = ta.getInt(R.styleable.CountDownView_startDuration, 0); textSize = ta.getDimensionPixelSize(R.styleable.CountDownView_android_textSize, (int) dpToPx(12, getResources())); textAppearanceRef = ta.getResourceId(R.styleable.CountDownView_android_textAppearance, 0); ta.recycle(); textPaint.setTextSize(textSize); if (textAppearanceRef != 0) { textAppearanceSpan = new TextAppearanceSpan(getContext(), textAppearanceRef); textPaint.setTextSize(textAppearanceSpan.getTextSize()); } setStartDuration(startDuration); }
Example #15
Source File: BoxThreadPoolExecutorActivity.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
/** * Helper method that returns formatted text that is meant to be shown in a Button * * @param title the title text that should be emphasized * @param description the description text that should be de-emphasized * @return Spannable that is the formatted text */ protected Spannable createTitledSpannable(final String title, final String description){ String combined = title +"\n"+ description; Spannable accessSpannable = new SpannableString(combined); accessSpannable.setSpan(new TextAppearanceSpan(this, R.style.Base_TextAppearance_AppCompat_Body1), title.length(),combined.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); accessSpannable.setSpan(new ForegroundColorSpan(R.color.box_hint_foreground), title.length(),combined.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return accessSpannable; }
Example #16
Source File: HeaderSpanCreator.java From writeily-pro with MIT License | 5 votes |
public ParcelableSpan create(Matcher m) { final char[] charSequence = extractMatchingRange(m); Float proportion = calculateProportionBasedOnHeaderType(charSequence); Float size = calculateAdjustedSize(proportion); return new TextAppearanceSpan(highlighter.fontType, Typeface.BOLD, (int) size.byteValue(), ColorStateList.valueOf(color), null); }
Example #17
Source File: Highlighter.java From writeily-pro with MIT License | 5 votes |
private void clearSpans(Editable e) { clearSpanType(e, TextAppearanceSpan.class); clearSpanType(e, ForegroundColorSpan.class); clearSpanType(e, BackgroundColorSpan.class); clearSpanType(e, StrikethroughSpan.class); clearSpanType(e, StyleSpan.class); }
Example #18
Source File: Html.java From MHViewer with Apache License 2.0 | 5 votes |
private static void endFont(SpannableStringBuilder text) { int len = text.length(); Object obj = getLast(text, Font.class); int where = text.getSpanStart(obj); text.removeSpan(obj); if (where != len) { Font f = (Font) obj; if (!TextUtils.isEmpty(f.mColor)) { if (f.mColor.startsWith("@")) { Resources res = Resources.getSystem(); String name = f.mColor.substring(1); int colorRes = res.getIdentifier(name, "color", "android"); text.setSpan(new TextAppearanceSpan(null, 0, 0, ColorStateList.valueOf(res.getColor(colorRes)), null), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { try { int c = getHtmlColor(f.mColor); text.setSpan(new ForegroundColorSpan(c | 0xFF000000), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (IllegalArgumentException e) { // Ignore } } } if (f.mFace != null) { text.setSpan(new TypefaceSpan(f.mFace), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } }
Example #19
Source File: SuggestionsAdapter.java From zhangshangwuda with Apache License 2.0 | 5 votes |
private CharSequence formatUrl(CharSequence url) { if (mUrlColor == null) { // Lazily get the URL color from the current theme. TypedValue colorValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true); mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId); } SpannableString text = new SpannableString(url); text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null), 0, url.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return text; }
Example #20
Source File: SuggestionsAdapter.java From Libraries-for-Android-Developers with MIT License | 5 votes |
private CharSequence formatUrl(CharSequence url) { if (mUrlColor == null) { // Lazily get the URL color from the current theme. TypedValue colorValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true); mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId); } SpannableString text = new SpannableString(url); text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null), 0, url.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return text; }
Example #21
Source File: SuggestionsAdapter.java From zen4android with MIT License | 5 votes |
private CharSequence formatUrl(CharSequence url) { if (mUrlColor == null) { // Lazily get the URL color from the current theme. TypedValue colorValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true); mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId); } SpannableString text = new SpannableString(url); text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null), 0, url.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return text; }
Example #22
Source File: ProfilePresenter.java From social-app-android with Apache License 2.0 | 5 votes |
public Spannable buildCounterSpannable(String label, int value) { SpannableStringBuilder contentString = new SpannableStringBuilder(); contentString.append(String.valueOf(value)); contentString.append("\n"); int start = contentString.length(); contentString.append(label); contentString.setSpan(new TextAppearanceSpan(context, R.style.TextAppearance_Second_Light), start, contentString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return contentString; }
Example #23
Source File: AFTagHandler.java From AndroidMathKeyboard with Apache License 2.0 | 5 votes |
/** * 还原为原来的颜色 * @param startIndex * @param stopIndex * @param editable */ private void reductionFontColor(int startIndex,int stopIndex,Editable editable){ if (null != mOriginColors){ editable.setSpan(new TextAppearanceSpan(null, 0, 0, mOriginColors, null), startIndex, stopIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); }else { editable.setSpan(new ForegroundColorSpan(0xff2b2b2b), startIndex, stopIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } }
Example #24
Source File: HtmlParser.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
private static void endFont(SpannableStringBuilder text) { int len = text.length(); Object obj = getLast(text, Font.class); int where = text.getSpanStart(obj); text.removeSpan(obj); if (where != len) { Font f = (Font) obj; if (!TextUtils.isEmpty(f.mColor)) { if (f.mColor.startsWith("@")) { Resources res = Resources.getSystem(); String name = f.mColor.substring(1); int colorRes = res.getIdentifier(name, "color", "android"); if (colorRes != 0) { ColorStateList colors = CompatibilityUtils.getColorStateList(res, colorRes); text.setSpan(new TextAppearanceSpan(null, 0, 0, colors, null), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { int c = ColorHidden.getHtmlColor(f.mColor); if (c != -1) { text.setSpan(new ForegroundColorSpan(c | 0xFF000000), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } } if (f.mFace != null) { text.setSpan(new TypefaceSpan(f.mFace), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } if (f.mStyle != null) { List<Object> styleSpans = parseStyleAttributes(f.mStyle); for (Object span : styleSpans) { text.setSpan(span, where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } } }
Example #25
Source File: CustomHtmlToSpannedConverter.java From zulip-android with Apache License 2.0 | 5 votes |
private static void endFont(SpannableStringBuilder text) { int len = text.length(); Object obj = getLast(text, Font.class); int where = text.getSpanStart(obj); text.removeSpan(obj); if (where != len) { Font f = (Font) obj; if (!TextUtils.isEmpty(f.mColor)) { if (f.mColor.startsWith("@")) { Resources res = Resources.getSystem(); String name = f.mColor.substring(1); int colorRes = res.getIdentifier(name, "color", "android"); if (colorRes != 0) { ColorStateList colors = res.getColorStateList(colorRes); text.setSpan(new TextAppearanceSpan(null, 0, 0, colors, null), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { int c = getHtmlColor(f.mColor); if (c != -1) { text.setSpan(new ForegroundColorSpan(c | 0xFF000000), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } } if (f.mFace != null) { text.setSpan(new TypefaceSpan(f.mFace), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } }
Example #26
Source File: CustomSetterActivity.java From AndroidMVVMSample with Apache License 2.0 | 5 votes |
@BindingAdapter("spanText") public static void setText(TextView textView, String value) { Log.d("BindingAdapter", "setText(TextView textView,String value)"); SpannableString styledText = new SpannableString(value); styledText.setSpan(new TextAppearanceSpan(textView.getContext(), R.style.style0), 0, 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); styledText.setSpan(new TextAppearanceSpan(textView.getContext(), R.style.style1), 5, 12, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); styledText.setSpan(new TextAppearanceSpan(textView.getContext(), R.style.style0), 12, value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(styledText, TextView.BufferType.SPANNABLE); }
Example #27
Source File: SwitchBar.java From android_external_MicroGUiTools with Apache License 2.0 | 5 votes |
public SwitchBar(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater.from(context).inflate(R.layout.switch_bar, this); mTextView = (TextView) findViewById(R.id.switch_text); if (SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { mTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); } mLabel = getResources().getString(R.string.abc_capital_off); mSummarySpan = new TextAppearanceSpan(context, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_Switch); updateText(); mSwitch = (ToggleSwitch) findViewById(R.id.switch_widget); // Prevent onSaveInstanceState() to be called as we are managing the state of the Switch // on our own mSwitch.setSaveEnabled(false); if (SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); } addOnSwitchChangeListener(new OnSwitchChangeListener() { @Override public void onSwitchChanged(SwitchCompat switchView, boolean isChecked) { setTextViewLabel(isChecked); } }); setOnClickListener(this); // Default is hide setVisibility(View.GONE); }
Example #28
Source File: StringStyleUtils.java From gank.io-unofficial-android-client with Apache License 2.0 | 5 votes |
public static SpannableString format(Context context, String text, int style) { SpannableString spannableString = new SpannableString(text); spannableString.setSpan(new TextAppearanceSpan(context, style), 0, text.length(), 0); return spannableString; }
Example #29
Source File: Html.java From Nimingban with Apache License 2.0 | 5 votes |
private static void endFont(SpannableStringBuilder text) { int len = text.length(); Object obj = getLast(text, Font.class); int where = text.getSpanStart(obj); text.removeSpan(obj); if (where != len) { Font f = (Font) obj; if (!TextUtils.isEmpty(f.mColor)) { if (f.mColor.startsWith("@")) { Resources res = Resources.getSystem(); String name = f.mColor.substring(1); int colorRes = res.getIdentifier(name, "color", "android"); text.setSpan(new TextAppearanceSpan(null, 0, 0, ColorStateList.valueOf(res.getColor(colorRes)), null), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { try { int c = getHtmlColor(f.mColor); text.setSpan(new ForegroundColorSpan(c | 0xFF000000), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (ParseException e) { // Ignore } } } if (f.mFace != null) { text.setSpan(new TypefaceSpan(f.mFace), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } }
Example #30
Source File: SuggestionsAdapter.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private CharSequence formatUrl(Context context, CharSequence url) { if (mUrlColor == null) { // Lazily get the URL color from the current theme. TypedValue colorValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true); mUrlColor = context.getColorStateList(colorValue.resourceId); } SpannableString text = new SpannableString(url); text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null), 0, url.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return text; }