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));
}
}
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());
}
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);
}
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;
}
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();
}
});
}
Aggregations