Search in sources :

Example 46 with SpannableString

use of android.text.SpannableString in project Signal-Android by WhisperSystems.

the class ComposeText method setHint.

public void setHint(@NonNull String hint, @Nullable CharSequence subHint) {
    this.hint = new SpannableString(hint);
    this.hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    if (subHint != null) {
        this.subHint = new SpannableString(subHint);
        this.subHint.setSpan(new RelativeSizeSpan(0.8f), 0, subHint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    } else {
        this.subHint = null;
    }
    if (this.subHint != null) {
        super.setHint(new SpannableStringBuilder().append(ellipsizeToWidth(this.hint)).append("\n").append(ellipsizeToWidth(this.subHint)));
    } else {
        super.setHint(ellipsizeToWidth(this.hint));
    }
}
Also used : SpannableString(android.text.SpannableString) RelativeSizeSpan(android.text.style.RelativeSizeSpan) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 47 with SpannableString

use of android.text.SpannableString in project Signal-Android by WhisperSystems.

the class RegistrationProgressActivity method initializeLinks.

private void initializeLinks() {
    TextView failureText = (TextView) findViewById(R.id.sms_failed_text);
    String pretext = getString(R.string.registration_progress_activity__signal_timed_out_while_waiting_for_a_verification_sms_message);
    String link = getString(R.string.RegistrationProblemsActivity_possible_problems);
    SpannableString spannableString = new SpannableString(pretext + " " + link);
    spannableString.setSpan(new ClickableSpan() {

        @Override
        public void onClick(View widget) {
            new AlertDialog.Builder(RegistrationProgressActivity.this).setTitle(R.string.RegistrationProblemsActivity_possible_problems).setView(R.layout.registration_problems).setNeutralButton(android.R.string.ok, null).show();
        }
    }, pretext.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    failureText.setText(spannableString);
    failureText.setMovementMethod(LinkMovementMethod.getInstance());
}
Also used : SpannableString(android.text.SpannableString) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 48 with SpannableString

use of android.text.SpannableString in project CircleDemo by Naoki2015.

the class PraiseListView method setClickableSpan.

@NonNull
private SpannableString setClickableSpan(String textStr, final int position) {
    SpannableString subjectSpanText = new SpannableString(textStr);
    subjectSpanText.setSpan(new SpannableClickable(itemColor) {

        @Override
        public void onClick(View widget) {
            if (onItemClickListener != null) {
                onItemClickListener.onClick(position);
            }
        }
    }, 0, subjectSpanText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return subjectSpanText;
}
Also used : SpannableString(android.text.SpannableString) TextView(android.widget.TextView) View(android.view.View) SpannableClickable(com.yiw.circledemo.spannable.SpannableClickable) NonNull(android.support.annotation.NonNull)

Example 49 with SpannableString

use of android.text.SpannableString in project 9GAG by Mixiaoxiao.

the class MxxBrowserActivity method setActionBarTitle.

private void setActionBarTitle(String title) {
    SpannableString spannableString = new SpannableString(title);
    String font = "LockScreen_Clock.ttf";
    spannableString.setSpan(new TypefaceSpan(font, Typeface.createFromAsset(getAssets(), font)), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    getActionBar().setTitle(spannableString);
}
Also used : SpannableString(android.text.SpannableString) SpannableString(android.text.SpannableString) TypefaceSpan(com.mixiaoxiao.android.view.TypefaceSpan)

Example 50 with SpannableString

use of android.text.SpannableString in project 9GAG by Mixiaoxiao.

the class MxxTextUtil method getTypefaceSpannableString.

public static SpannableString getTypefaceSpannableString(Context context, String string, String fontName) {
    SpannableString spannableString = new SpannableString(string);
    spannableString.setSpan(new TypefaceSpan(fontName, Typeface.createFromAsset(context.getAssets(), fontName), false), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannableString;
}
Also used : SpannableString(android.text.SpannableString) TypefaceSpan(com.mixiaoxiao.android.view.TypefaceSpan)

Aggregations

SpannableString (android.text.SpannableString)325 TextView (android.widget.TextView)61 Spannable (android.text.Spannable)60 View (android.view.View)57 StyleSpan (android.text.style.StyleSpan)53 ForegroundColorSpan (android.text.style.ForegroundColorSpan)47 TextPaint (android.text.TextPaint)25 Spanned (android.text.Spanned)24 TextAppearanceSpan (android.text.style.TextAppearanceSpan)21 Paint (android.graphics.Paint)20 RelativeSizeSpan (android.text.style.RelativeSizeSpan)19 ImageView (android.widget.ImageView)19 Bundle (android.os.Bundle)17 TypedValue (android.util.TypedValue)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)16 Intent (android.content.Intent)15 SpannableStringBuilder (android.text.SpannableStringBuilder)15 ClickableSpan (android.text.style.ClickableSpan)14 URLSpan (android.text.style.URLSpan)13 LayoutInflater (android.view.LayoutInflater)13