当前位置: 首页>>代码示例>>Java>>正文


Java CalligraphyTypefaceSpan类代码示例

本文整理汇总了Java中uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan的典型用法代码示例。如果您正苦于以下问题:Java CalligraphyTypefaceSpan类的具体用法?Java CalligraphyTypefaceSpan怎么用?Java CalligraphyTypefaceSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CalligraphyTypefaceSpan类属于uk.co.chrisjenx.calligraphy包,在下文中一共展示了CalligraphyTypefaceSpan类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTimeDay

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
private void setTimeDay(TextView textView, String day) {
    final Resources resources = textView.getResources();
    final String suffix = resources.getString(R.string.txt_day);
    final int dayLen = day.length();

    SpannableStringBuilder sBuilder = new SpannableStringBuilder();
    sBuilder.append(day) // Bold this
            .append('\n') // Default TextView font.
            .append(suffix); // Default TextView font.

    // Create the Typeface you want to apply to certain text
    CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(resources.getAssets(), "fonts/Hero.otf"));
    sBuilder.setSpan(typefaceSpan, 0, dayLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    // Font
    sBuilder.setSpan(new AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen.font_24)),
            0, dayLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    // Color
    sBuilder.setSpan(new ForegroundColorSpan(resources.getColor(R.color.cyan_700)),
            0, dayLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    textView.setText(sBuilder, TextView.BufferType.SPANNABLE);
}
 
开发者ID:qiujuer,项目名称:UPMiss,代码行数:23,代码来源:RecordsViewHolder.java

示例2: onViewCreated

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
@Override public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    Bundle args = this.getArguments();
    if (args != null && args.containsKey(I_EXTRA_FROM)){
        fromHelp = true;
    }

    // Using a custom typeface for an EditText with inputType="textPassword"
    // requires java intervention because XML automatically uses the default typeface
    Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), CalligraphyConfig.get().getFontPath());
    passwordLayout.setTypeface(typeface);

    CalligraphyTypefaceSpan typefaceSpan = TypefaceUtils.getSpan(typeface);
    SpannableString spannableString = new SpannableString(getString(R.string.password));
    spannableString.setSpan(typefaceSpan, 0, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

    passwordLayout.setHint(spannableString);
}
 
开发者ID:SpartaHack,项目名称:SpartaHack-Android,代码行数:20,代码来源:ProfileFragment.java

示例3: boldClosedDay

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
private void boldClosedDay(final int field) {
  final String text = mClosedDays.getText().toString();

  int start = 0;
  for (int i = 0; i < field; i++) {
    start = text.indexOf('\n', start + 1);
    if (start == -1) {
      // Run out of fields!
      return;
    }
  }

  int end = text.indexOf('\n', start + 1);
  if (end == -1) {
    end = text.length();
  }

  final Typeface boldFont = FontUtils.getFont(FontUtils.MEDIUM);

  final SpannableString ss = new SpannableString(text);
  ss.setSpan(new CalligraphyTypefaceSpan(boldFont), start, end, 0);
  mClosedDays.setText(ss);
}
 
开发者ID:cdeange,项目名称:uwaterloo-api,代码行数:24,代码来源:LocationFragment.java

示例4: mCustomiseScriptSpan

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
private void mCustomiseScriptSpan(MetricAffectingSpan[] spanArray, SpannableStringBuilder builder) {
    for(MetricAffectingSpan metricAffectingSpan : spanArray) {
        int start = builder.getSpanStart(metricAffectingSpan);
        int end = builder.getSpanEnd(metricAffectingSpan);

        RelativeSizeSpan sizeSpan = new RelativeSizeSpan(0.6f);

        builder.setSpan(sizeSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.setSpan(new CalligraphyTypefaceSpan(mBoldItalicTypeface), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
开发者ID:andrei-egeniq,项目名称:android-tibits,代码行数:12,代码来源:MainActivity.java

示例5: initTitle

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
private void initTitle() {
    SpannableStringBuilder sBuilder = new SpannableStringBuilder();
    sBuilder.append(getTitle()); // Bold this
    // Create the Typeface you want to apply to certain text
    try {
        CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/Lobster.otf"));
        // Apply typeface to the Spannable 0 - 6 "Hello!" This can of course by dynamic.
        sBuilder.setSpan(typefaceSpan, 0, sBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mToolbar.setTitle(sBuilder);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
}
 
开发者ID:qiujuer,项目名称:UPMiss,代码行数:14,代码来源:MainActivity.java

示例6: setTitle

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
@Override
public void setTitle(CharSequence title) {
    // Get title
    CharSequence sequence = null;
    if (mToolbar != null)
        sequence = mToolbar.getTitle();
    // Format title
    SpannableStringBuilder sBuilder;
    if (sequence != null && sequence instanceof SpannableStringBuilder) {
        sBuilder = (SpannableStringBuilder) sequence;
        sBuilder.clearSpans();
        sBuilder.clear();
    } else {
        sBuilder = new SpannableStringBuilder();
    }

    // Add title
    sBuilder.append(title);
    // Create the Typeface you want to apply to certain text
    Typeface typeface = TypefaceUtils.load(getAssets(), getTitleFont());
    CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(typeface);
    sBuilder.setSpan(typefaceSpan, 0, sBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    // Set title
    super.setTitle(sBuilder);
    if (mToolbar != null)
        mToolbar.setTitle(sBuilder);
}
 
开发者ID:PowerBack,项目名称:AnKey,代码行数:28,代码来源:SuperActivity.java

示例7: getTextWithFont

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
/**
 * use font to title
 * @param title
 * @param fontPath the path of font which is in assert directory
 * @return a fontable title text
 */
public static SpannableStringBuilder getTextWithFont(Context context,String title, String fontPath){
    // init builder
    SpannableStringBuilder sBuilder = new SpannableStringBuilder();
    // Add title
    sBuilder.append(title);

    // Create the Typeface you want to apply to certain text
    Typeface typeface = TypefaceUtils.load(context.getAssets(), fontPath);
    CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(typeface);
    sBuilder.setSpan(typefaceSpan, 0, sBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    return sBuilder;
}
 
开发者ID:PowerBack,项目名称:AnKey,代码行数:20,代码来源:FormatUtil.java

示例8: wrapInCustomfont

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
/**
 *
 * @param myText
 * @param contextWeakRefer
 * @return
 */
public static Spannable wrapInCustomfont(String myText, WeakReference<Context> contextWeakRefer) {
    Typeface typeface = Typeface.createFromAsset(contextWeakRefer.get().getAssets(), "fonts/chimphand-regular.ttf");
    CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(typeface);
    SpannableString spannable = new SpannableString(myText);
    spannable.setSpan(typefaceSpan, 0, myText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannable;
}
 
开发者ID:dadoz,项目名称:UnCafe,代码行数:14,代码来源:Utils.java

示例9: onCreate

import uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simpler_views);
    AppCompatActivitySetup.with(this)
            .supportAppBar(R.id.app_bar)
            .upButton();

    //<editor-fold desc="Some Typeface Loading">
    final AssetManager assets = getAssets();
    final Typeface typefaceA =
            TypefaceUtils.load(assets, getString(R.string.font_path_merriweather_regular));
    final Typeface typefaceB =
            TypefaceUtils.load(assets, getString(R.string.font_path_clear_sans));
    //</editor-fold>

    final SpannableStringBuilder builder =
            new SpannableStringBuilder(getString(R.string.simpler_views_text_B02));
    int start = 0;
    int end = builder.length();
    builder.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_LLL_DialogueB),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new CalligraphyTypefaceSpan(typefaceB),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    //<editor-fold desc="More Spannable Stuff…">
    start = end;
    builder.append("\n\n").append(getString(R.string.simpler_views_text_A03));
    end = builder.length();
    builder.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_LLL_DialogueA),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new CalligraphyTypefaceSpan(typefaceA),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    start = end;
    builder.append("\n\n").append(getString(R.string.simpler_views_text_B03));
    end = builder.length();
    builder.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_LLL_DialogueB),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new CalligraphyTypefaceSpan(typefaceB),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    //</editor-fold>

    final TextView textView = ButterKnife.findById(this, R.id.simple_text);
    textView.setText(builder, TextView.BufferType.SPANNABLE);
}
 
开发者ID:queencodemonkey,项目名称:Presentation-Loving-Lean-Layouts,代码行数:51,代码来源:SimplerViewsActivity.java


注:本文中的uk.co.chrisjenx.calligraphy.CalligraphyTypefaceSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。