androidx.core.graphics.TypefaceCompat Java Examples
The following examples show how to use
androidx.core.graphics.TypefaceCompat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SatelliteMenuView.java From CrazyDaily with Apache License 2.0 | 5 votes |
public void setImgText(ImgTextEntity entity) { final Context context = getContext(); TextView textView = new TextView(context); @SuppressLint("RestrictedApi") Typeface typeface = TypefaceCompat.createFromResourcesFontFile(context, getResources(), R.font.crazydailyicon, "", 0); textView.setTypeface(typeface); textView.setText(entity.text); textView.setTextSize(SIZE * BUTTON_RATIO * TEXT_RATIO); OvalShape shape = new OvalShape(); PaintDrawable shapeDrawable = new PaintDrawable(entity.color); shapeDrawable.setShape(shape); textView.setTextColor(Color.WHITE); textView.setBackground(shapeDrawable); textView.setGravity(Gravity.CENTER); final int size = (int) (SIZE * BUTTON_RATIO); LayoutParams params = new LayoutParams(size, size); params.gravity = Gravity.END | Gravity.BOTTOM; addView(textView, params); mButtonView = textView; mButtonView.setOnClickListener(v -> { if (isOpen) { close(); } else { show(); } }); }
Example #2
Source File: TypefaceCompatBaseImpl.java From Carbon with Apache License 2.0 | 5 votes |
@Nullable public Typeface createFromFontFamilyFilesResourceEntry(Context context, FontFamilyFilesResourceEntry entry, Resources resources, boolean isTargetItalic, int targetWeight) { FontFileResourceEntry best = findBestEntry(entry, isTargetItalic, targetWeight); if (best == null) { return null; } final Typeface typeface = TypefaceCompat.createFromResourcesFontFile( context, resources, best.getResourceId(), best.getFileName(), 0); addFontFamily(typeface, entry); return typeface; }