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 Project: ShadowsocksRR   Author: xhvay   File: ProfileManagerActivity.java    License: Apache License 2.0 6 votes vote down vote up
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 #2
Source Project: ShadowsocksRR   Author: xhvay   File: ProfileManagerActivity.java    License: Apache License 2.0 6 votes vote down vote up
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 #3
Source Project: Maying   Author: huio   File: ProfileManagerActivity.java    License: Apache License 2.0 6 votes vote down vote up
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 #4
Source Project: Maying   Author: huio   File: ProfileManagerActivity.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: MultiContactPicker   Author: broakenmedia   File: MultiContactPickerAdapter.java    License: Apache License 2.0 6 votes vote down vote up
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 #6
Source Project: myapplication   Author: absentm   File: FindSearchAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@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 #7
Source Project: tindroid   Author: tinode   File: ContactsAdapter.java    License: Apache License 2.0 6 votes vote down vote up
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 #8
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 Project: Applozic-Android-SDK   Author: AppLozic   File: ChannelFragment.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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
/**
 * 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 Project: Applozic-Android-SDK   Author: AppLozic   File: AppContactFragment.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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 Project: WayHoo   Author: way1989   File: QueryCityActivity.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: codeexamples-android   Author: vogellacompany   File: MainActivity.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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 Project: CountDownView   Author: alexfu   File: CountDownView.java    License: MIT License 6 votes vote down vote up
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 Project: android_9.0.0_r45   Author: lulululbj   File: SuggestionsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #16
Source Project: MHViewer   Author: axlecho   File: Html.java    License: Apache License 2.0 5 votes vote down vote up
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 #17
Source Project: social-app-android   Author: emonm   File: ProfilePresenter.java    License: Apache License 2.0 5 votes vote down vote up
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 #18
Source Project: AndroidMathKeyboard   Author: tianshaokai   File: AFTagHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 还原为原来的颜色
 * @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 #19
Source Project: DebugOverlay-Android   Author: Manabu-GT   File: MemInfoViewModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDataAvailable(MemInfo data) {
    ActivityManager.MemoryInfo systemMemInfo = data.getSystemMemInfo();
    Debug.MemoryInfo procMemInfo = data.getProcessMemInfo();

    if (DebugOverlay.isDebugLoggingEnabled()) {
        Log.d(TAG, "MemTotal(MB):" + DECIMAL_FORMAT.format(systemMemInfo.totalMem / 1048576f));
        Log.d(TAG, "MemAvail(MB):" + DECIMAL_FORMAT.format(systemMemInfo.availMem / 1048576f));
        Log.d(TAG, "MemThreshold(MB):" + DECIMAL_FORMAT.format(systemMemInfo.threshold / 1048576f));
        Log.d(TAG, "TotalPss(MB):" + DECIMAL_FORMAT.format(procMemInfo.getTotalPss() / 1024f));
        Log.d(TAG, "TotalPrivateDirty(MB):" + DECIMAL_FORMAT.format(procMemInfo.getTotalPrivateDirty() / 1024f));
    }
    
    if (memInfoTxtView != null) {
        StringBuilder builder = new StringBuilder(HEADER);
        builder.append(DECIMAL_FORMAT.format(systemMemInfo.availMem / 1048576f)).append(" ")
                .append(DECIMAL_FORMAT.format(procMemInfo.getTotalPss() / 1024f)).append(" ")
                .append(DECIMAL_FORMAT.format(procMemInfo.getTotalPrivateDirty() / 1024f));

        SpannableStringBuilder spannableBuilder = new SpannableStringBuilder(builder.toString());
        if (systemMemInfo.lowMemory) {
            spannableBuilder.setSpan(
                    new TextAppearanceSpan(memInfoTxtView.getContext(), R.style.debugoverlay_LowMemoryTextAppearance),
                    HEADER.length(),
                    spannableBuilder.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
            );
        }
        memInfoTxtView.setText(spannableBuilder);
    }
}
 
Example #20
Source Project: CSipSimple   Author: treasure-lau   File: SuggestionsAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
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 Project: Protein   Author: gejiaheng   File: AboutFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.getNavigationIcon().setColorFilter(
            getResources().getColor(R.color.icon_grey), PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());

    int padding = getResources().getDimensionPixelSize(R.dimen.about_header_padding);
    bannerImage.setPadding(padding, padding, padding, padding);
    Glide.with(this)
            .load(R.drawable.egg)
            .into(bannerImage);

    Spannable span = new SpannableString(title.getContext().getString(R.string.about_title));
    span.setSpan(new TextAppearanceSpan(title.getContext(),
                    R.style.ProteinTextAppearance_Regular_XXL_Primary), 0, 7,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    span.setSpan(new TextAppearanceSpan(title.getContext(),
                    R.style.ProteinTextAppearance_Regular_L_Hint), 7, span.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    title.setText(span);
    versionName.setText(versionName.getContext().getString(R.string.about_version, BuildConfig.VERSION_NAME));

    layoutGe.setOnClickListener(aboutOnClickListener);
    layoutMelodie.setOnClickListener(aboutOnClickListener);
    layoutOthers.setOnClickListener(aboutOnClickListener);
    versionLayout.setOnClickListener(aboutOnClickListener);
    licenseLayout.setOnClickListener(aboutOnClickListener);
    shareLayout.setOnClickListener(aboutOnClickListener);
}
 
Example #22
Source Project: SpanEZ   Author: yombunker   File: SpanEZTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ResourceType")
@Test
public void appearance_should_add_only_one_span() {
    spanBuilder.appearance(range, INTEGER_ARG)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(TextAppearanceSpan.class));
}
 
Example #23
Source Project: CurveView   Author: auv1107   File: CurveView.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Mark(String content, int gravity, int marginStart, int marginTop, int marginEnd, int marginBottom, TextAppearanceSpan mTextAppearanceSpan) {
    this.content = content;
    this.gravity = gravity;
    this.marginStart = marginStart;
    this.marginEnd = marginEnd;
    this.marginTop = marginTop;
    this.marginBottom = marginBottom;
    this.textAppearanceSpan = mTextAppearanceSpan;
}
 
Example #24
Source Project: spanner   Author: neworld   File: Spans.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @see android.text.style.TextAppearanceSpan#TextAppearanceSpan(String, int, int, ColorStateList, ColorStateList)
 */
public static Span appearance(@Nullable final String family, final int style, final int size, @Nullable final ColorStateList color, @Nullable final ColorStateList linkColor) {
    return new Span(new SpanBuilder() {
        @Override
        public Object build() {
            return new TextAppearanceSpan(family, style, size, color, linkColor);
        }
    });
}
 
Example #25
Source Project: social-app-android   Author: rozdoum   File: ProfilePresenter.java    License: Apache License 2.0 5 votes vote down vote up
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 #26
Source Project: hintcase   Author: Nescafemix   File: SimpleHintContentHolder.java    License: Apache License 2.0 5 votes vote down vote up
private View getTextViewTitle(Context context) {
    LinearLayout.LayoutParams linearLayoutParamsTitle =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayoutParamsTitle.setMargins(0, 20, 0, 20);
    TextView textViewTitle = new TextView(context);
    textViewTitle.setLayoutParams(linearLayoutParamsTitle);
    textViewTitle.setGravity(Gravity.CENTER_HORIZONTAL);
    SpannableString spannableStringTitle= new SpannableString(contentTitle);
    TextAppearanceSpan titleTextAppearanceSpan = new TextAppearanceSpan(context, titleStyleId);
    spannableStringTitle.setSpan(titleTextAppearanceSpan, 0, spannableStringTitle.length(), 0);
    textViewTitle.setText(spannableStringTitle);
    return textViewTitle;
}
 
Example #27
Source Project: hintcase   Author: Nescafemix   File: SimpleHintContentHolder.java    License: Apache License 2.0 5 votes vote down vote up
private View getTextViewDescription(Context context) {
    LinearLayout.LayoutParams linearLayoutParamsText =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    TextView textViewDescription = new TextView(context);
    textViewDescription.setLayoutParams(linearLayoutParamsText);
    textViewDescription.setGravity(Gravity.CENTER_HORIZONTAL);
    SpannableString spannableStringText= new SpannableString(contentText);
    TextAppearanceSpan textTextAppearanceSpan = new TextAppearanceSpan(context, textStyleId);
    spannableStringText.setSpan(textTextAppearanceSpan, 0, spannableStringText.length(), 0);
    textViewDescription.setText(spannableStringText);
    return textViewDescription;
}
 
Example #28
Source Project: hintcase   Author: Nescafemix   File: CustomHintContentHolder.java    License: Apache License 2.0 5 votes vote down vote up
private View getTextViewTitle(Context context) {
    LinearLayout.LayoutParams linearLayoutParamsTitle =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayoutParamsTitle.setMargins(0, 0, 0, 20);
    TextView textViewTitle = new TextView(context);
    textViewTitle.setLayoutParams(linearLayoutParamsTitle);
    textViewTitle.setGravity(Gravity.CENTER_HORIZONTAL);
    SpannableString spannableStringTitle= new SpannableString(contentTitle);
    TextAppearanceSpan titleTextAppearanceSpan = new TextAppearanceSpan(context, titleStyleId);
    spannableStringTitle.setSpan(titleTextAppearanceSpan, 0, spannableStringTitle.length(), 0);
    textViewTitle.setText(spannableStringTitle);
    return textViewTitle;
}
 
Example #29
Source Project: hintcase   Author: Nescafemix   File: CustomHintContentHolder.java    License: Apache License 2.0 5 votes vote down vote up
private View getTextViewDescription(Context context) {
    LinearLayout.LayoutParams linearLayoutParamsText =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    TextView textViewDescription = new TextView(context);
    textViewDescription.setLayoutParams(linearLayoutParamsText);
    textViewDescription.setGravity(Gravity.CENTER_HORIZONTAL);
    SpannableString spannableStringText= new SpannableString(contentText);
    TextAppearanceSpan textTextAppearanceSpan = new TextAppearanceSpan(context, textStyleId);
    spannableStringText.setSpan(textTextAppearanceSpan, 0, spannableStringText.length(), 0);
    textViewDescription.setText(spannableStringText);
    return textViewDescription;
}
 
Example #30
Source Project: text-decorator   Author: nntuyen   File: TextDecorator.java    License: Apache License 2.0 5 votes vote down vote up
public TextDecorator setTextAppearance(final int appearance, final int start, final int end) {
  checkIndexOutOfBoundsException(start, end);
  decoratedContent.setSpan(new TextAppearanceSpan(textView.getContext(), appearance), start, end,
      flags);

  return this;
}