Search in sources :

Example 16 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 17 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 18 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 19 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)

Example 20 with SpannableString

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

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MxxSystemBarTintUtil.setSystemBarTintColor(this);
    SpannableString spannableString = new SpannableString("9GAG");
    String font = "LockScreen_Clock.ttf";
    spannableString.setSpan(new TypefaceSpan(font, Typeface.createFromAsset(getAssets(), font)), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    getActionBar().setTitle(spannableString);
    getActionBar().setDisplayShowHomeEnabled(false);
    setContentView(R.layout.activity_main);
    mViewPager = (ViewPager) findViewById(R.id.main_viewpager);
    //		scaleImageView = (MxxScaleImageView) findViewById(R.id.main_mxxScaleImageView1);
    mViewPager.setOffscreenPageLimit(3);
    mTabStrip = (MxxPagerSlidingTabStrip) findViewById(R.id.main_tab);
    ArrayList<Fragment> fragments = new ArrayList<Fragment>();
    fragments.add(new GagFragmentHot());
    fragments.add(new GagFragmentTrending());
    fragments.add(new GagFragmentFresh());
    mViewPager.setAdapter(new GagAdapter2(getSupportFragmentManager(), fragments, new String[] { "hot", "trending", "fresh" }));
    mTabStrip.setViewPager(mViewPager);
    initTint();
    mTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub
            if (((ViewGroup) tabLayout).getChildAt(0).getTranslationY() != 0) {
                ((ViewGroup) tabLayout).getChildAt(0).setTranslationY(0);
            }
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        // TODO Auto-generated method stub
        }
    });
    mImageFragment = (ImageFragment) getSupportFragmentManager().findFragmentById(R.id.main_image_fragment);
    mTabStrip.post(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            getSupportFragmentManager().beginTransaction().hide(mImageFragment).commit();
        }
    });
}
Also used : GagFragmentTrending(com.mixiaoxiao.ninegag.fragment.GagFragmentTrending) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) ImageFragment(com.mixiaoxiao.ninegag.fragment.ImageFragment) Fragment(android.support.v4.app.Fragment) GagFragment(com.mixiaoxiao.ninegag.fragment.GagFragment) ViewPager(android.support.v4.view.ViewPager) SpannableString(android.text.SpannableString) GagFragmentFresh(com.mixiaoxiao.ninegag.fragment.GagFragmentFresh) GagFragmentHot(com.mixiaoxiao.ninegag.fragment.GagFragmentHot) TypefaceSpan(com.mixiaoxiao.android.view.TypefaceSpan)

Aggregations

SpannableString (android.text.SpannableString)319 Spannable (android.text.Spannable)60 TextView (android.widget.TextView)60 View (android.view.View)56 StyleSpan (android.text.style.StyleSpan)53 ForegroundColorSpan (android.text.style.ForegroundColorSpan)45 TextPaint (android.text.TextPaint)25 Spanned (android.text.Spanned)22 TextAppearanceSpan (android.text.style.TextAppearanceSpan)21 Paint (android.graphics.Paint)20 ImageView (android.widget.ImageView)19 RelativeSizeSpan (android.text.style.RelativeSizeSpan)18 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)13 URLSpan (android.text.style.URLSpan)13 LayoutInflater (android.view.LayoutInflater)13