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


Java TypefaceUtils.load方法代码示例

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


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

示例1: setTimeDay

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的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: applyTypefaceOnTitle

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的package包/类
private void applyTypefaceOnTitle(Toolbar toolbar, String title) {
    try {
        for (int i = 0; i < toolbar.getChildCount(); ++i) {
            View child = toolbar.getChildAt(i);
            if (child instanceof TextView) {
                Typeface mTypeface = TypefaceUtils.load(getAssets(), "fonts/Roboto/Roboto-Bold.ttf");
                if (((TextView) child).getText().toString().equalsIgnoreCase(title)) {
                    CalligraphyUtils.applyFontToTextView((TextView)child, mTypeface);
                    break;
                }
            }
        }
    } catch (Exception e) {
        Log.e("BaseActivity", "Fail to apply typeface on toolbar");
    }
}
 
开发者ID:brunogabriel,项目名称:giyp-android,代码行数:17,代码来源:BaseActivity.java

示例3: onCreateView

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.session_feedback_frag, container, false);
    mCollapsingToolbar =
            (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    final Typeface productSans =
            TypefaceUtils.load(getContext().getAssets(), "fonts/ProductSans-Regular.ttf");
    mCollapsingToolbar.setExpandedTitleTypeface(productSans);
    mCollapsingToolbar.setCollapsedTitleTypeface(productSans);
    mSpeakers = (TextView) rootView.findViewById(R.id.feedback_header_session_speakers);
    mOverallFeedbackBar = (CustomRatingBar) rootView.findViewById(R.id.rating_bar_0);
    mSessionRelevantFeedbackBar = (CustomRatingBar) rootView.findViewById(
            R.id.session_relevant_feedback_bar);
    mContentFeedbackBar = (CustomRatingBar) rootView.findViewById(R.id.content_feedback_bar);
    mSpeakerFeedbackBar = (CustomRatingBar) rootView.findViewById(R.id.speaker_feedback_bar);
    rootView.findViewById(R.id.submit_feedback_button).setOnClickListener(
            new OnClickListener() {
                @Override
                public void onClick(View view) {
                    submitFeedback();
                }
            }
    );
    return rootView;
}
 
开发者ID:google,项目名称:iosched,代码行数:27,代码来源:SessionFeedbackFragment.java

示例4: initTitle

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的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

示例5: getTypefaceByText

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的package包/类
public static Typeface getTypefaceByText(String text) {
    Pattern RTL_CHAR = Pattern.compile("[\u0600-\u06FF\u0750-\u077F\u0590-\u05FF\uFE70-\uFEFF]");
    Matcher matcher = RTL_CHAR.matcher(text);
    if (matcher.find()) {
        //load persian default font
        return TypefaceUtils.load(TApplication.applicationContext.getAssets(), TApplication.applicationContext.getString(R.string.normal_persian_font));
    } else {
        return TypefaceUtils.load(TApplication.applicationContext.getAssets(), TApplication.applicationContext.getString(R.string.normal_latin_font));
    }
}
 
开发者ID:atahani,项目名称:telepathy-android,代码行数:11,代码来源:AndroidUtilities.java

示例6: setTitle

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的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.TypefaceUtils; //导入方法依赖的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: DiscussionPostsAdapter

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的package包/类
@Inject
public DiscussionPostsAdapter(Context context, IEdxEnvironment environment) {
    super(context, R.layout.row_discussion_thread, environment);
    edx_brand_primary_base = context.getResources().getColor(R.color.edx_brand_primary_base);
    edx_grayscale_neutral_dark = context.getResources().getColor(R.color.edx_brand_gray_base);
    edx_brand_secondary_dark = context.getResources().getColor(R.color.edx_brand_secondary_dark);
    edx_utility_success_dark = context.getResources().getColor(R.color.edx_success_text);
    openSansSemiBoldFont = TypefaceUtils.load(context.getAssets(), "fonts/OpenSans-Semibold.ttf");
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:10,代码来源:DiscussionPostsAdapter.java

示例9: onItemSelected

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    Typeface typeface = TypefaceUtils.load(getAssets(), "fonts/" + fonts.get(position).getFileName());
    binding.fillerTextView.setTypeface(typeface);
}
 
开发者ID:bignerdranch,项目名称:Typesetter,代码行数:6,代码来源:TypesetterActivity.java

示例10: onCreate

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的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

示例11: getFont

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入方法依赖的package包/类
public static Typeface getFont(final @Font int font) {
  final String fontPath = FONTS.get(font);
  return TypefaceUtils.load(sAssets, fontPath);
}
 
开发者ID:cdeange,项目名称:uwaterloo-api,代码行数:5,代码来源:FontUtils.java


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