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


Java Typeface类代码示例

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


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

示例1: getTextWidth

import android.graphics.Typeface; //导入依赖的package包/类
private static int getTextWidth(@Nullable final CharSequence text, final TextPaint paint) {
    if (TextUtils.isEmpty(text)) {
        return 0;
    }
    final int length = text.length();
    final float[] widths = new float[length];
    final int count;
    final Typeface savedTypeface = paint.getTypeface();
    try {
        paint.setTypeface(getTextTypeface(text));
        count = paint.getTextWidths(text, 0, length, widths);
    } finally {
        paint.setTypeface(savedTypeface);
    }
    int width = 0;
    for (int i = 0; i < count; i++) {
        width += Math.round(widths[i] + 0.5f);
    }
    return width;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:21,代码来源:SuggestionStripLayoutHelper.java

示例2: onCreate

import android.graphics.Typeface; //导入依赖的package包/类
/**
 * Main initialization of the input method component.  Be sure to call
 * to super class.
 */
@Override public void onCreate() {
    super.onCreate();
    mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    mWordSeparators = getResources().getString(R.string.word_separators);
    mSuggestions = EMPTY_LIST;
    mQuranSuggestions = EMPTY_MLIST;
    mSavedPreSpaces = 0;

    try {
        mQuranSearch = new QuranSearch(this);
    } catch (IOException |SecurityException e) {
        mQuranSearch = null;
        Toast.makeText(this, "Quran Search disabled, File not found!", Toast.LENGTH_LONG).show();
        // TODO disable/gray the Moshaf/shift key & disable/grey Prefs
        if (DEBUG) e.printStackTrace();
    }

    if (mQuranSearch != null) {
        PreferenceManager.setDefaultValues(this, R.xml.ime_preferences, false);

        setUthmaniTypeFace(Typeface.createFromAsset(getAssets(), "UthmanicHafs.otf"));
    }
}
 
开发者ID:cdjalel,项目名称:QuranKeyboard,代码行数:28,代码来源:QuranKeyboardIME.java

示例3: getDefaultAttr

import android.graphics.Typeface; //导入依赖的package包/类
private static SnipettyAttr getDefaultAttr(Context context) {
	SnipettyAttr attr = new SnipettyAttr();

	Resources resources = context.getResources();
	attr.leadGap = resources.getDimensionPixelOffset(R.dimen.space_medium);
	attr.gapWidth = resources.getDimensionPixelOffset(R.dimen.space_xlarge);
	attr.textColor = ContextCompat.getColor(context, R.color.secondary_text);
	attr.titleTextSize = resources.getDimensionPixelOffset(R.dimen.text_xlarge);
	attr.subTitleTextSize = resources.getDimensionPixelOffset(R.dimen.text_medium);
	attr.titleTextColor = ContextCompat.getColor(context, R.color.primary_text);
	attr.subTitleTextColor = ContextCompat.getColor(context, R.color.primary_text);
	attr.titleTextFont = Typeface.createFromAsset(context.getAssets(),
			context.getString(R.string.font_roboto_bold));
	attr.subtitleTextFont = Typeface.createFromAsset(context.getAssets(),
			context.getString(R.string.font_roboto_medium));

	return attr;
}
 
开发者ID:Fueled,项目名称:snippety,代码行数:19,代码来源:SnippetyUtil.java

示例4: populateAdditionalHeadersView

import android.graphics.Typeface; //导入依赖的package包/类
/**
 * Set up the additional headers text view with the supplied header data.
 *
 * @param additionalHeaders List of header entries. Each entry consists of a header
 *                          name and a header value. Header names may appear multiple
 *                          times.
 *                          <p/>
 *                          This method is always called from within the UI thread by
 *                          {@link #showAdditionalHeaders()}.
 */
private void populateAdditionalHeadersView(final List<HeaderEntry> additionalHeaders) {
    SpannableStringBuilder sb = new SpannableStringBuilder();
    boolean first = true;
    for (HeaderEntry additionalHeader : additionalHeaders) {
        if (!first) {
            sb.append("\n");
        } else {
            first = false;
        }
        StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
        SpannableString label = new SpannableString(additionalHeader.label + ": ");
        label.setSpan(boldSpan, 0, label.length(), 0);
        sb.append(label);
        sb.append(MimeUtility.unfoldAndDecode(additionalHeader.value));
    }
    mAdditionalHeadersView.setText(sb);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:28,代码来源:MessageHeader.java

示例5: getSystemFontMap

import android.graphics.Typeface; //导入依赖的package包/类
/**
 * Return Typeface.sSystemFontMap.
 *
 * @return Typeface.sSystemFontMap
 */
@SuppressWarnings("unchecked")
@Nullable
public static Map<String, Typeface> getSystemFontMap() {
    if (!available) {
        return null;
    }

    if (sSystemFontMap == null) {
        try {
            sSystemFontMap = (Map<String, Typeface>) sSystemFontMapField.get(null);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return null;
        }
    }

    return sSystemFontMap;
}
 
开发者ID:RikkaApps,项目名称:FontProvider,代码行数:24,代码来源:TypefaceCompat.java

示例6: createTitleView

import android.graphics.Typeface; //导入依赖的package包/类
private RelativeLayout createTitleView(Context context) {
  RelativeLayout view = new RelativeLayout(context);
  view.setLayoutParams(new LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

  TextView title = new TextView(context);
  title.setPadding(0, SizeUtil.dp5, 0, SizeUtil.dp5);
  title.setGravity(Gravity.CENTER);
  title.setText(options.getTitle());
  title.setTextColor(options.getTitleColor());
  title.setTextSize(TypedValue.COMPLEX_UNIT_SP, SizeUtil.textSize0);
  title.setTypeface(null, Typeface.BOLD);
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
  layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
  title.setLayoutParams(layoutParams);

  view.addView(title, title.getLayoutParams());
  return view;
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:22,代码来源:BaseMessageDialog.java

示例7: makeTextView

import android.graphics.Typeface; //导入依赖的package包/类
private void makeTextView() {
    loadTextViewStyleAttributes();
    textView.setText(text);
    if (textColor != 0) {
        textView.setTextColor(textColor);
    }

    if (textSize > 0) {
        textView.setTextSize(isTextSizeFromStyle ? 0 : TypedValue.COMPLEX_UNIT_SP, textSize);
    }

    if (textBold && typeface == null) {
        textView.setTypeface(Typeface.create(context.getString(R.string.default_font), Typeface.BOLD));
    } else if (textBold) {
        textView.setTypeface(Typeface.create(typeface, Typeface.BOLD));
    } else if (typeface != null) {
        textView.setTypeface(typeface);
        //TODO THIS CHECK IS DEPRECATED AND WILL BE DELETED SOON
    } else if (fontId > 0) {
        textView.setTypeface(ResourcesCompat.getFont(context, fontId));
    }
}
 
开发者ID:Muddz,项目名称:StyleableToast,代码行数:23,代码来源:StyleableToast.java

示例8: getView

import android.graphics.Typeface; //导入依赖的package包/类
/****************************************************************
 * getView
 * 		the overroad getView method */
public View getView(int position, View convertView, ViewGroup parent) 
{
	// get the view that would normally be returned
	View v = super.getView(position, convertView, parent);
	final TextView tv = (TextView) v;
	
	final String option = tv.getText().toString();			
	if (option.equals("Serif"))
		tv.setTypeface(Typeface.SERIF);
	else if (option.equals("Sans Serif"))
		tv.setTypeface(Typeface.SANS_SERIF);
	else if (option.equals("Monospace"))
		tv.setTypeface(Typeface.MONOSPACE);

	// general options
	tv.setTextColor(Color.BLACK);
	tv.setPadding(10, 3, 3, 3);

	return v;	
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:24,代码来源:FontTypePreference.java

示例9: setTextStyle

import android.graphics.Typeface; //导入依赖的package包/类
public void setTextStyle(int style) {
        if(isInEditMode())
            return;

        String font;
        switch (style) {
            case Typeface.BOLD:
                font = Stylish.FONT_BOLD;
                break;
            case Typeface.ITALIC:
                font = Stylish.FONT_ITALIC;
                break;
            case Typeface.NORMAL:
                font = Stylish.FONT_REGULAR;
                break;
            default:
                font = Stylish.FONT_REGULAR;
        }

        try {

            setTypeface(Stylish.getInstance().getTypeface(getContext(), font, getTypeface()));
        } catch (Exception e) {
//            e.printStackTrace();
        }
    }
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:27,代码来源:ATextView.java

示例10: custom

import android.graphics.Typeface; //导入依赖的package包/类
public static Toast custom(@NonNull Context context, CharSequence text, @Nullable Drawable icon,
                           @ColorInt int backgroundColor, int duration, @DrawableRes int resid,
                           @Nullable Typeface tp, float cornerRadius,
                           @ColorInt int textColor, float textSize) {
    Toast toast = new Toast(context);

    View layout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.toast_layout, null);
    LinearLayout ll = (LinearLayout) layout.findViewById(R.id.base_layout);
    ll.setBackgroundResource(resid);
    GradientDrawable gd = (GradientDrawable) ll.getBackground().getCurrent();
    gd.setColor(backgroundColor);
    gd.setCornerRadius(cornerRadius);
    TextView tv_message = (TextView) layout.findViewById(R.id.toast_text);
    tv_message.setTextSize(textSize);
    tv_message.setTypeface(tp == null ? DEFAULT_TYPEFACE : tp);
    tv_message.setTextColor(textColor);
    ImageView iv_toast_image = (ImageView) layout.findViewById(R.id.toast_image);
    if (icon != null) {
        iv_toast_image.setImageDrawable(icon);
    }
    tv_message.setText(text);
    toast.setView(layout);
    toast.setDuration(duration);
    return toast;
}
 
开发者ID:chugh22,项目名称:ButterToast,代码行数:27,代码来源:ButterToast.java

示例11: onCreate

import android.graphics.Typeface; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.homepage);

    hellokuet = (TextView) findViewById(R.id.hellokuet);
    Email = (EditText) findViewById(R.id.input_email);
    Password = (EditText) findViewById(R.id.input_password);
    login = (Button) findViewById(R.id.btn_login);

    ttf1 = Typeface.createFromAsset(getAssets(),"fonts/trench100free.ttf");
    hellokuet.setTypeface(ttf1);


    login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Intent ints = new Intent(home.this , MainActivity.class);
           //startActivity(ints);
        }
    });



}
 
开发者ID:area101BD,项目名称:Hello-KUET,代码行数:26,代码来源:home.java

示例12: initialisePaint

import android.graphics.Typeface; //导入依赖的package包/类
private void initialisePaint() {

        // Calculate radiuses i n px from dp based on screen density
        float density = getResources().getDisplayMetrics().density;
        mCircleRadius = CIRCLE_RADIUS_DP * density;
        //we want to know the screen width to make the white text remain in the screen
        Configuration configuration = getContext().getResources().getConfiguration();
        mScreenWidth = configuration.smallestScreenWidthDp * (int) density ;
        //mCircleHistoricalRadius = CIRCLE_HISTORICAL_RADIUS_DP * density;

        // Setup text paint for circle label
        mTextPaint.setTextSize(30f*density);
        mStrokePaint.setTextSize(30f*density);
        mTextPaint.setColor(Color.WHITE);
        mStrokePaint.setColor(Color.WHITE);
        mTransStrokePaint.setColor(Color.WHITE);
        mTextPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mStrokePaint.setStrokeWidth(6f* density);
        mTransStrokePaint.setStyle(Paint.Style.STROKE);
        mTransStrokePaint.setStrokeWidth(6f* density);

    }
 
开发者ID:ndleyton,项目名称:OneTwo,代码行数:24,代码来源:TouchDisplayView.java

示例13: checkGenericFont

import android.graphics.Typeface; //导入依赖的package包/类
private Typeface checkGenericFont(String fontName, Integer fontWeight,
		FontStyle fontStyle) {
	Typeface font = null;
	int typefaceStyle;

	boolean italic = (fontStyle == Style.FontStyle.Italic);
	typefaceStyle = (fontWeight > 500) ? (italic ? Typeface.BOLD_ITALIC
			: Typeface.BOLD) : (italic ? Typeface.ITALIC : Typeface.NORMAL);

	if (fontName.equals("serif")) {
		font = Typeface.create(Typeface.SERIF, typefaceStyle);
	} else if (fontName.equals("sans-serif")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	} else if (fontName.equals("monospace")) {
		font = Typeface.create(Typeface.MONOSPACE, typefaceStyle);
	} else if (fontName.equals("cursive")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	} else if (fontName.equals("fantasy")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	}
	return font;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:23,代码来源:SVGAndroidRenderer.java

示例14: onBindViewHolder

import android.graphics.Typeface; //导入依赖的package包/类
@Override
protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull final VideoItem item) {
    if (item.data.cover.homePageCover != null) {
        Glide.with(mActivity).load(item.data.cover.homePageCover).into(holder.imageButton);
    } else {
        Glide.with(mActivity).load(item.data.cover.detailCover).into(holder.imageButton);
    }
    holder.imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mActivity, MovieDetailActivity.class);
            Bundle bundle = new Bundle();
            bundle.putParcelable("DATA", item.data);
            intent.putExtras(bundle);
            mActivity.startActivity(intent);
        }
    });

    holder.title.setText(item.data.title);
    holder.title.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.DB1FontPath)));
    holder.info.setText("#" + item.data.category + "  /  " + TranslateDuration.translateSeconds(item.data.duration));
    holder.info.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.LFontPath)));
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:24,代码来源:VideoItemBinder.java

示例15: createDialogSelection

import android.graphics.Typeface; //导入依赖的package包/类
public void createDialogSelection(String title , int selection, MaterialDialog.ListCallbackSingleChoice callbackSingleChoice, MaterialDialog.SingleButtonCallback positive, int index){
    new MaterialDialog.Builder(mContext)
            .title(title)
            .items(selection)
            .typeface(Typeface.SANS_SERIF,Typeface.SANS_SERIF)
            .iconRes(app_prefs.isLightTheme()?R.drawable.ic_view_list_black_24dp:R.drawable.ic_view_list_white_24dp)
            .buttonRippleColorRes(R.color.colorAccent)
            .positiveColorRes(R.color.colorStateBlue)
            .negativeColorRes(R.color.colorStateOrange)
            .theme(app_prefs.isLightTheme()?Theme.LIGHT:Theme.DARK)
            .itemsCallbackSingleChoice(index, callbackSingleChoice)
            .positiveText(R.string.Apply)
            .neutralText(R.string.Cancel)
            .onPositive(positive)
            .onNeutral(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    dialog.dismiss();
                }
            })
            .show();
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:23,代码来源:DialogManager.java


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