• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TypefaceUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TypefaceUtils类属于uk.co.chrisjenx.calligraphy包,在下文中一共展示了TypefaceUtils类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: initWith

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入依赖的package包/类
private void initWith(Context context, AttributeSet attrs) {
  paint = new Paint();
  paint.setTextAlign(Paint.Align.CENTER);
  paint.setAntiAlias(true);
  paint.setColor(Color.BLACK);
  TypedArray typedArray = context.getTheme()
      .obtainStyledAttributes(attrs, R.styleable.MultipleRowTextView, 0, 0);
  try {
    float textSizePixel = typedArray.getDimension(
        R.styleable.MultipleRowTextView_multiRowTextSize,
        getResources().getDimension(R.dimen.normal_text_size));
    int textSizeSp = DisplayUtil.px2sp(context, textSizePixel);
    mFontSize = DisplayUtil.sp2px(context, textSizeSp);
  } finally {
    typedArray.recycle();
  }
  setTypeface(TypefaceUtils.load(context.getAssets(), "fonts/jianshi_default.otf"));
}
 
开发者ID:wingjay,项目名称:jianshi,代码行数:19,代码来源:MultipleRowTextView.java


示例4: init

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入依赖的package包/类
private void init(AttributeSet attrs) {
  TypedArray typedArray = context.getTheme()
      .obtainStyledAttributes(attrs, R.styleable.TextPointView, 0, 0);
  singleText = typedArray.getString(R.styleable.TextPointView_text);
  circleColorRes = typedArray.getInt(R.styleable.TextPointView_redPointViewBgColor, R.color.bright_red);
  textSize = typedArray.getDimensionPixelSize(R.styleable.TextPointView_textSize, DEFAULT_TEXT_SIZE);
  typedArray.recycle();

  circleView = new View(context);
  circleView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT));
  setCircleBackgroundColor(circleColorRes);

  textView = new TextView(context);
  FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
      ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  params.gravity = Gravity.CENTER;
  textView.setLayoutParams(params);
  textView.setTypeface(TypefaceUtils.load(context.getAssets(), "fonts/jianshi_default.otf"));
  textView.setTextSize(textSize);
  textView.setTextColor(ContextCompat.getColor(context, R.color.white));
  textView.setText(singleText);

  addView(circleView);
  addView(textView);
}
 
开发者ID:wingjay,项目名称:jianshi,代码行数:27,代码来源:TextPointView.java


示例5: onViewCreated

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


示例6: 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


示例7: 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


示例8: 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


示例9: onTextChanged

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入依赖的package包/类
@Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
    if (!TextUtils.isEmpty(text)) {
        Pattern RTL_CHAR = Pattern.compile("[\u0600-\u06FF\u0750-\u077F\u0590-\u05FF\uFE70-\uFEFF]");
        Matcher matcher = RTL_CHAR.matcher(text.toString());
        if (matcher.find()) {
            //load persian default font
            setTypeface(TypefaceUtils.load(TApplication.applicationContext.getAssets(), TApplication.applicationContext.getString(R.string.normal_persian_font)));

        } else {
            setTypeface(TypefaceUtils.load(TApplication.applicationContext.getAssets(), TApplication.applicationContext.getString(R.string.normal_latin_font)));
        }
    }
    super.onTextChanged(text, start, lengthBefore, lengthAfter);
}
 
开发者ID:atahani,项目名称:telepathy-android,代码行数:16,代码来源:DetectLEditText.java


示例10: 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


示例11: 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


示例12: 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


示例13: ReadingChunk

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入依赖的package包/类
public ReadingChunk(Context context, String pinyin, String hanzi, String definition) {
    this.pinyin = pinyin;
    this.hanzi = hanzi;
    this.definition = definition;

    // Calculate the width of each line of text to find the widest
    TextView pinyinTextView = new TextView(context);
    pinyinTextView.setText(getPinyin());
    pinyinTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R
            .dimen.item_reading_default_pinyin_text_size));
    Rect pinyinBounds = new Rect();
    pinyinTextView.getPaint().getTextBounds(getPinyin(), 0, pinyin.length(), pinyinBounds);

    TextView hanziTextView = new TextView(context);
    hanziTextView.setText(getHanzi());
    hanziTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension
            (R.dimen
            .item_reading_default_hanzi_text_size));
    hanziTextView.setTypeface(TypefaceUtils.load(context.getAssets(), "fonts/BabelStoneHan.ttf"));
    Rect hanziBounds = new Rect();
    hanziTextView.getPaint().getTextBounds(getHanzi(), 0, hanzi.length(), hanziBounds);

    TextView definitionTextView = new TextView(context);
    definitionTextView.setText(getDefinition());
    definitionTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R
            .dimen.item_reading_default_definition_text_size));
    Rect definitionBounds = new Rect();
    definitionTextView.getPaint().getTextBounds(getDefinition(), 0, definitionTextView.length(),
            definitionBounds);

    width = Math.max(Math.max(pinyinBounds.width(), hanziBounds.width()),
            definitionBounds.width()) + context.getResources().getDimensionPixelSize(R.dimen.item_reading_padding);
}
 
开发者ID:asm-products,项目名称:kanshu-android,代码行数:34,代码来源:ReadingChunk.java


示例14: 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


示例15: 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


示例16: init

import uk.co.chrisjenx.calligraphy.TypefaceUtils; //导入依赖的package包/类
private void init() {
        if (!isInEditMode()) {
        setTypeface(TypefaceUtils.load(getContext().getAssets(), "fonts/BabelStoneHan.ttf"));
//      setTypeface(TypefaceUtils.load(getContext().getAssets(), "fonts/NotoSansCJKsc-Regular.otf"));
        }
    }
 
开发者ID:asm-products,项目名称:kanshu-android,代码行数:7,代码来源:ChineseTextView.java


示例17: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZoomDensity类代码示例发布时间:2022-05-21
下一篇:
Java ViewProps类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap