Here are the examples of the java api android.graphics.Typeface taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1672 Examples
19
Source : HeadSpan.java
with MIT License
from zzhoujay
with MIT License
from zzhoujay
private static void applyStyle(Paint paint) {
int style = Typeface.BOLD;
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
int want = oldStyle | style;
Typeface tf;
if (old == null) {
tf = Typeface.defaultFromStyle(want);
} else {
tf = Typeface.create(old, want);
}
int fake = want & ~tf.getStyle();
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(tf);
}
19
Source : OptionsPickerView.java
with Apache License 2.0
from zyyoona7
with Apache License 2.0
from zyyoona7
/**
* 设置当前字体
*
* @param typeface 字体
*/
public void setTypeface(Typeface typeface) {
mOptionsWv1.setTypeface(typeface);
mOptionsWv2.setTypeface(typeface);
mOptionsWv3.setTypeface(typeface);
}
19
Source : DatePickerView.java
with Apache License 2.0
from zyyoona7
with Apache License 2.0
from zyyoona7
/**
* 设置WheelView 字体
*
* @param tf 字体
*/
public void setTypeface(Typeface tf) {
mYearWv.setTypeface(tf);
mMonthWv.setTypeface(tf);
mDayWv.setTypeface(tf);
}
19
Source : TypefaceHelper.java
with GNU General Public License v3.0
from zyl409214686
with GNU General Public License v3.0
from zyl409214686
public static Typeface getTypeface(Context context, String fileName) {
Typeface tempTypeface = sTypeFaces.get(fileName);
if (tempTypeface == null) {
String fontPath = new StringBuilder(TYPEFACE_FOLDER).append('/').append(fileName).append(TYPEFACE_EXTENSION).toString();
tempTypeface = Typeface.createFromreplacedet(context.getreplacedets(), fontPath);
sTypeFaces.put(fileName, tempTypeface);
}
return tempTypeface;
}
19
Source : AvatarRenderer.java
with GNU Affero General Public License v3.0
from zood
with GNU Affero General Public License v3.0
from zood
/**
* This does the heavy lifting for the AvatarView clreplaced. The functionality was separated out of the View
* clreplaced, so it could also be leveraged off the main thread for rendering the icon used for Google Maps
* markers.
*/
public clreplaced AvatarRenderer {
private static Typeface montserratBold;
private float diameter;
private float radius;
private Bitmap image;
private final Paint imagePaint;
private final Paint bgPaint;
private StaticLayout layout;
private BitmapShader shader;
private final TextPaint textPaint;
private int textWidth;
private float fontDescent;
private String username;
@AnyThread
AvatarRenderer(@NonNull Context ctx, boolean isInEditMode) {
imagePaint = new Paint();
imagePaint.setAntiAlias(true);
bgPaint = new Paint();
bgPaint.setAntiAlias(true);
bgPaint.setStyle(Paint.Style.FILL);
textPaint = new TextPaint();
if (!isInEditMode) {
// I don't know why font resources can't be loaded in edit mode
if (montserratBold == null) {
montserratBold = ResourcesCompat.getFont(ctx, R.font.montserrat_bold);
}
textPaint.setTypeface(montserratBold);
fontDescent = textPaint.getFontMetrics().descent;
}
textPaint.setAntiAlias(true);
if (isInEditMode) {
setUsername("zood");
}
}
@AnyThread
void draw(@NonNull Canvas canvas) {
if (image == null && TextUtils.isEmpty(username)) {
canvas.drawColor(Color.WHITE);
return;
}
if (image == null) {
// no image, so draw the letter
canvas.drawRoundRect(0, 0, diameter, diameter, radius, radius, bgPaint);
canvas.save();
canvas.translate((diameter - textWidth) / 2.0f, fontDescent * 3);
layout.draw(canvas);
canvas.restore();
} else {
canvas.drawRoundRect(0, 0, diameter, diameter, radius, radius, imagePaint);
}
}
@AnyThread
@NonNull
public static BitmapDescriptor getBitmapDescriptor(@NonNull Context ctx, @NonNull String username, @DimenRes int sizeRes) {
int size = ctx.getResources().getDimensionPixelSize(sizeRes);
Bitmap img = null;
try {
img = Picreplacedo.with(ctx).load(AvatarManager.getAvatar(ctx, username)).resize(size, size).get();
} catch (IOException ignore) {
}
AvatarRenderer renderer = new AvatarRenderer(ctx, false);
renderer.setUsername(username);
renderer.setDiameter(size);
if (img != null) {
renderer.setImage(img);
}
Bitmap avatar = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(avatar);
renderer.draw(c);
return BitmapDescriptorFactory.fromBitmap(avatar);
}
@NonNull
private static ColorPair getColorPair(byte val) {
// we want the unsigned value
int num = val & 0xFF;
if (num < 42) {
// blue
return new ColorPair(Color.parseColor("#5CD1FF"), Color.WHITE);
} else if (num < 85) {
// red
return new ColorPair(Color.parseColor("#E41C16"), Color.WHITE);
} else if (num < 128) {
// navy
return new ColorPair(Color.parseColor("#3C4466"), Color.WHITE);
} else if (num < 170) {
// orange
return new ColorPair(Color.parseColor("#F6921E"), Color.WHITE);
} else if (num < 213) {
// canary
return new ColorPair(Color.parseColor("#FFE422"), Color.parseColor("#46585E"));
} else {
// grey
return new ColorPair(Color.parseColor("#46585E"), Color.WHITE);
}
}
@AnyThread
private static byte[] getMD5Hash(@NonNull String data) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(data.getBytes(Constants.utf8));
return digest.digest();
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException("MD5 algo not found", ex);
}
}
private void recalculateDrawVariables() {
textPaint.setTextSize(diameter * 0.6f);
if (!TextUtils.isEmpty(username)) {
String txt = username.charAt(0) + "";
txt = txt.toUpperCase(Locale.US);
textWidth = (int) textPaint.measureText(txt);
if (Build.VERSION.SDK_INT >= 23) {
layout = StaticLayout.Builder.obtain(txt, 0, 1, textPaint, textWidth).setAlignment(Layout.Alignment.ALIGN_CENTER).setIncludePad(true).build();
} else {
layout = new StaticLayout(txt, textPaint, textWidth, Layout.Alignment.ALIGN_CENTER, 0, 0, true);
}
} else {
layout = null;
}
if (image != null) {
float xScale = diameter / (float) image.getWidth();
float yScale = diameter / (float) image.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(xScale, yScale);
shader.setLocalMatrix(matrix);
}
}
@AnyThread
void setDiameter(float diameter) {
this.diameter = diameter;
this.radius = diameter / 2.0f;
recalculateDrawVariables();
}
void setImage(@Nullable Bitmap img) {
this.image = img;
if (img == null) {
imagePaint.setShader(null);
shader = null;
} else {
shader = new BitmapShader(image, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
imagePaint.setShader(shader);
}
recalculateDrawVariables();
}
@AnyThread
public void setUsername(@NonNull String username) {
this.username = username;
ColorPair colors = getColorPair(getMD5Hash(username)[15]);
textPaint.setColor(colors.foreground);
bgPaint.setColor(colors.background);
image = null;
imagePaint.setShader(null);
recalculateDrawVariables();
}
private static clreplaced ColorPair {
@ColorInt
final int foreground;
@ColorInt
final int background;
@AnyThread
ColorPair(@ColorInt int background, @ColorInt int foreground) {
this.background = background;
this.foreground = foreground;
}
}
}
19
Source : FontUtils.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
/**
* Gets roboto typeface according to preplaceded typeface style settings.
* <p/>
* Will get Roboto-Bold for Typeface.BOLD etc
*/
private static Typeface getRobotoTypeface(Context context, Typeface originalTypeface) {
FontType robotoFontType = null;
if (originalTypeface == null) {
robotoFontType = FontType.NORMAL;
} else {
int style = originalTypeface.getStyle();
switch(style) {
case Typeface.BOLD:
robotoFontType = FontType.BOLD;
break;
case Typeface.BOLD_ITALIC:
robotoFontType = FontType.BOLD_ITALIC;
break;
case Typeface.ITALIC:
robotoFontType = FontType.ITALIC;
break;
default:
robotoFontType = FontType.NORMAL;
break;
}
}
return getRobotoTypeface(context, robotoFontType);
}
19
Source : FontUtils.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
/**
* Walks ViewGroups, finds TextViews and applies Typefaces taking styling in consideration
*
* @param context - to reach replacedets
* @param view - root view to apply typeface to
*/
public static void setRobotoFont(Context context, View view) {
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
setRobotoFont(context, ((ViewGroup) view).getChildAt(i));
}
} else if (view instanceof TextView) {
Typeface currentTypeface = ((TextView) view).getTypeface();
((TextView) view).setTypeface(getRobotoTypeface(context, currentTypeface));
}
}
19
Source : SplashActivity.java
with Apache License 2.0
from zjutkz
with Apache License 2.0
from zjutkz
private void setFont() {
Typeface typeface = Typeface.createFromreplacedet(getreplacedets(), "fonts/introduction.TTF");
introduction.setTypeface(typeface);
}
19
Source : MainActivity.java
with Apache License 2.0
from zjutkz
with Apache License 2.0
from zjutkz
private void configToolbar() {
TextView replacedle = (TextView) findViewById(R.id.replacedle);
Typeface typeface = Typeface.createFromreplacedet(getreplacedets(), "fonts/introduction.TTF");
replacedle.setTypeface(typeface);
}
19
Source : TapIntroHelper.java
with Apache License 2.0
from zixpo
with Apache License 2.0
from zixpo
public static void showWallpaperPreviewIntro(@NonNull Context context, @ColorInt int color) {
if (Preferences.get(context).isTimeToShowWallpaperPreviewIntro()) {
AppCompatActivity activity = (AppCompatActivity) context;
View rootView = activity.findViewById(R.id.rootview);
if (rootView == null)
return;
new Handler().postDelayed(() -> {
try {
int baseColor = color;
if (baseColor == 0) {
baseColor = ColorHelper.getAttributeColor(context, R.attr.colorAccent);
}
int primary = ColorHelper.getreplacedleTextColor(baseColor);
int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
tapTargetSequence.continueOnCancel(true);
Typeface replacedle = TypefaceHelper.getMedium(context);
// Todo:
// Typeface description = TypefaceHelper.getRegular(context);
View apply = rootView.findViewById(R.id.menu_apply);
View save = rootView.findViewById(R.id.menu_save);
TapTarget tapTarget = TapTarget.forView(apply, context.getResources().getString(R.string.tap_intro_wallpaper_preview_apply), context.getResources().getString(R.string.tap_intro_wallpaper_preview_apply_desc)).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).outerCircleColorInt(baseColor).drawShadow(true);
TapTarget tapTarget1 = TapTarget.forView(save, context.getResources().getString(R.string.tap_intro_wallpaper_preview_save), context.getResources().getString(R.string.tap_intro_wallpaper_preview_save_desc)).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).outerCircleColorInt(baseColor).drawShadow(true);
if (replacedle != null) {
// Todo:
// tapTarget.replacedleTypeface(replacedle);
// tapTarget1.replacedleTypeface(replacedle);
// tapTarget2.replacedleTypeface(replacedle);
tapTarget.textTypeface(replacedle);
tapTarget1.textTypeface(replacedle);
}
// if (description != null) {
// Todo:
// tapTarget.descriptionTypeface(description);
// tapTarget1.descriptionTypeface(description);
// tapTarget2.descriptionTypeface(description);
// }
tapTargetSequence.target(tapTarget);
if (context.getResources().getBoolean(R.bool.enable_wallpaper_download)) {
tapTargetSequence.target(tapTarget1);
}
tapTargetSequence.listener(new TapTargetSequence.Listener() {
@Override
public void onSequenceFinish() {
Preferences.get(context).setTimeToShowWallpaperPreviewIntro(false);
}
@Override
public void onSequenceStep(TapTarget tapTarget, boolean b) {
}
@Override
public void onSequenceCanceled(TapTarget tapTarget) {
}
});
tapTargetSequence.start();
} catch (Exception e) {
LogUtil.e(Log.getStackTraceString(e));
}
}, 100);
}
}
19
Source : TapIntroHelper.java
with Apache License 2.0
from zixpo
with Apache License 2.0
from zixpo
@SuppressLint("StringFormatInvalid")
@SuppressWarnings("ConstantConditions")
public static void showHomeIntros(@NonNull Context context, @Nullable RecyclerView recyclerView, @Nullable StaggeredGridLayoutManager manager, int position) {
if (Preferences.get(context).isTimeToShowHomeIntro()) {
AppCompatActivity activity = (AppCompatActivity) context;
Toolbar toolbar = activity.findViewById(R.id.toolbar);
new Handler().postDelayed(() -> {
try {
int primary = ColorHelper.getAttributeColor(context, R.attr.toolbar_icon);
int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
tapTargetSequence.continueOnCancel(true);
Typeface replacedle = TypefaceHelper.getMedium(context);
// Todo:
// Typeface description = TypefaceHelper.getRegular(context);
if (toolbar != null) {
TapTarget tapTarget = TapTarget.forToolbarNavigationIcon(toolbar, context.getResources().getString(R.string.tap_intro_home_navigation), context.getResources().getString(R.string.tap_intro_home_navigation_desc)).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
if (replacedle != null) {
tapTarget.textTypeface(replacedle);
}
// Todo:
// if (description != null) {
// tapTarget.descriptionTypeface(description);
// }
tapTargetSequence.target(tapTarget);
}
if (recyclerView != null) {
HomeAdapter adapter = (HomeAdapter) recyclerView.getAdapter();
if (adapter != null) {
if (context.getResources().getBoolean(R.bool.enable_apply)) {
if (position >= 0 && position < adapter.gereplacedemCount()) {
RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
if (holder != null) {
View view = holder.itemView;
if (view != null) {
float targetRadius = toDp(context, view.getMeasuredWidth()) - 20f;
String desc = String.format(context.getResources().getString(R.string.tap_intro_home_apply_desc), context.getResources().getString(R.string.app_name));
TapTarget tapTarget = TapTarget.forView(view, context.getResources().getString(R.string.tap_intro_home_apply), desc).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).targetRadius((int) targetRadius).tintTarget(false).drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
if (replacedle != null) {
tapTarget.textTypeface(replacedle);
}
// if (description != null) {
// tapTarget.descriptionTypeface(description);
// }
tapTargetSequence.target(tapTarget);
}
}
}
}
}
}
tapTargetSequence.listener(new TapTargetSequence.Listener() {
@Override
public void onSequenceFinish() {
Preferences.get(context).setTimeToShowHomeIntro(false);
}
@Override
public void onSequenceStep(TapTarget tapTarget, boolean b) {
if (manager != null) {
if (position >= 0)
manager.scrollToPosition(position);
}
}
@Override
public void onSequenceCanceled(TapTarget tapTarget) {
}
});
tapTargetSequence.start();
} catch (Exception e) {
LogUtil.e(Log.getStackTraceString(e));
}
}, 100);
}
}
19
Source : TapIntroHelper.java
with Apache License 2.0
from zixpo
with Apache License 2.0
from zixpo
public static void showIconsIntro(@NonNull Context context) {
if (Preferences.get(context).isTimeToShowIconsIntro()) {
AppCompatActivity activity = (AppCompatActivity) context;
Toolbar toolbar = activity.findViewById(R.id.toolbar);
if (toolbar == null)
return;
new Handler().postDelayed(() -> {
try {
int primary = ColorHelper.getAttributeColor(context, R.attr.toolbar_icon);
int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
Typeface replacedle = TypefaceHelper.getMedium(context);
TapTarget tapTarget = TapTarget.forToolbarMenuItem(toolbar, R.id.menu_search, context.getResources().getString(R.string.tap_intro_icons_search), context.getResources().getString(R.string.tap_intro_icons_search_desc)).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
if (replacedle != null) {
tapTarget.textTypeface(replacedle);
}
// if (description != null) {
// tapTarget.descriptionTypeface(description);
// }
TapTargetView.showFor(activity, tapTarget, new TapTargetView.Listener() {
@Override
public void onTargetDismissed(TapTargetView view, boolean userInitiated) {
super.onTargetDismissed(view, userInitiated);
Preferences.get(context).setTimeToShowIconsIntro(false);
}
});
} catch (Exception e) {
LogUtil.e(Log.getStackTraceString(e));
}
}, 100);
}
}
19
Source : TapIntroHelper.java
with Apache License 2.0
from zixpo
with Apache License 2.0
from zixpo
@SuppressLint("StringFormatInvalid")
public static void showWallpapersIntro(@NonNull Context context, @Nullable RecyclerView recyclerView) {
if (Preferences.get(context).isTimeToShowWallpapersIntro()) {
AppCompatActivity activity = (AppCompatActivity) context;
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
new Handler().postDelayed(() -> {
int primary = ColorHelper.getAttributeColor(context, R.attr.toolbar_icon);
int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
if (recyclerView != null) {
TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
tapTargetSequence.continueOnCancel(true);
int position = 0;
if (recyclerView.getAdapter() == null)
return;
if (position < recyclerView.getAdapter().gereplacedemCount()) {
RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
if (holder == null)
return;
View view = holder.itemView.findViewById(R.id.image);
if (view != null) {
float targetRadius = toDp(context, view.getMeasuredWidth()) - 10f;
Typeface replacedle = TypefaceHelper.getMedium(context);
String desc = String.format(context.getResources().getString(R.string.tap_intro_wallpapers_option_desc), context.getResources().getBoolean(R.bool.enable_wallpaper_download) ? context.getResources().getString(R.string.tap_intro_wallpapers_option_desc_download) : "");
TapTarget tapTarget = TapTarget.forView(view, context.getResources().getString(R.string.tap_intro_wallpapers_option), desc).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).targetRadius((int) targetRadius).tintTarget(false).drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
TapTarget tapTarget1 = TapTarget.forView(view, context.getResources().getString(R.string.tap_intro_wallpapers_preview), context.getResources().getString(R.string.tap_intro_wallpapers_preview_desc)).replacedleTextColorInt(primary).descriptionTextColorInt(secondary).targetCircleColorInt(primary).targetRadius((int) targetRadius).tintTarget(false).drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
if (replacedle != null) {
tapTarget.textTypeface(replacedle);
tapTarget1.textTypeface(replacedle);
}
// if (description != null) {
// tapTarget.descriptionTypeface(description);
// tapTarget1.descriptionTypeface(description);
// }
tapTargetSequence.target(tapTarget);
tapTargetSequence.target(tapTarget1);
tapTargetSequence.listener(new TapTargetSequence.Listener() {
@Override
public void onSequenceFinish() {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
Preferences.get(context).setTimeToShowWallpapersIntro(false);
}
@Override
public void onSequenceStep(TapTarget tapTarget, boolean b) {
}
@Override
public void onSequenceCanceled(TapTarget tapTarget) {
}
});
tapTargetSequence.start();
}
}
}
}, 200);
}
}
19
Source : FileUtil.java
with MIT License
from zion223
with MIT License
from zion223
public static void setIconFont(String path, TextView textView) {
final Typeface typeface = Typeface.createFromreplacedet(Latte.getApplication().getreplacedets(), path);
textView.setTypeface(typeface);
}
19
Source : IconfontTextView.java
with Apache License 2.0
from zhangliangming
with Apache License 2.0
from zhangliangming
private void init(Context context) {
// 设置字体图片
Typeface iconfont = FontUtil.getInstance(context).getTypeFace();
setTypeface(iconfont);
}
19
Source : IconfontIndicatorTextView.java
with Apache License 2.0
from zhangliangming
with Apache License 2.0
from zhangliangming
private void init(Context context) {
// 设置字体图片
Typeface iconfont = FontUtil.getInstance(context).getTypeFace();
setTypeface(iconfont);
setClickable(true);
}
19
Source : FontUtil.java
with Apache License 2.0
from zhangliangming
with Apache License 2.0
from zhangliangming
/**
* 加载字体
*
* @author zhangliangming
*/
public clreplaced FontUtil {
/**
* 字体
*/
private static Typeface typeFace;
private static FontUtil _FontUtil;
public FontUtil(Context context) {
typeFace = Typeface.createFromreplacedet(context.getreplacedets(), "fonts/iconfont.ttf");
}
public static FontUtil getInstance(Context context) {
if (_FontUtil == null) {
_FontUtil = new FontUtil(context);
}
return _FontUtil;
}
public Typeface getTypeFace() {
return typeFace;
}
}
19
Source : LrcImg2VideoActivity.java
with Apache License 2.0
from zhangliangming
with Apache License 2.0
from zhangliangming
/**
* 生成歌词图片
*/
private void createLrcImage() {
if (mLrcFilePath == null || mLrcFilePath.equals("")) {
Toast.makeText(getApplicationContext(), "请选择歌词文件!", Toast.LENGTH_SHORT).show();
return;
}
File lrcFile = new File(mLrcFilePath);
if (!lrcFile.exists()) {
Toast.makeText(getApplicationContext(), "歌词文件不存在,请重新选择歌词文件!", Toast.LENGTH_SHORT).show();
return;
}
int outputLrcTypeRadioButtonId = mOutputLrcTypeRadioGroup.getCheckedRadioButtonId();
if (outputLrcTypeRadioButtonId == -1) {
Toast.makeText(getApplicationContext(), "请选择输出歌词类型!", Toast.LENGTH_SHORT).show();
return;
}
if (check()) {
// 视图宽度
String viewWidthString = mLrcDialogWidthEt.getText().toString();
mViewWidth = Integer.parseInt(viewWidthString);
// 视图高度
String viewHeightString = mLrcDialogHeightEt.getText().toString();
mViewHeight = Integer.parseInt(viewHeightString);
// 字体大小
String fontsizeString = mLrcFontSizeEt.getText().toString();
float lrcFontSize = Float.parseFloat(fontsizeString);
// 歌词空行高度
String lineHeightString = mLrcLineHeightEt.getText().toString();
mLineHeight = Float.parseFloat(lineHeightString);
// 歌词左右间隔
String paddingString = mLrcPaddingEt.getText().toString();
mPaddingLeftOrRight = Float.parseFloat(paddingString);
mFontSize = ScreenUtil.px2sp(getApplicationContext(), lrcFontSize);
// 设置字体文件
Typeface typeFace = Typeface.createFromreplacedet(getreplacedets(), "fonts/weiruanyahei14M.ttf");
// 默认画笔
mPaint = new Paint();
mPaint.setDither(true);
mPaint.setAntiAlias(true);
mPaint.setTextSize(mFontSize);
mPaint.setTypeface(typeFace);
// 高亮画笔
mPaintHL = new Paint();
mPaintHL.setDither(true);
mPaintHL.setAntiAlias(true);
mPaintHL.setTextSize(mFontSize);
mPaintHL.setTypeface(typeFace);
// 轮廓画笔
mPaintOutline = new Paint();
mPaintOutline.setDither(true);
mPaintOutline.setAntiAlias(true);
mPaintOutline.setColor(Color.BLACK);
mPaintOutline.setTextSize(mFontSize);
mPaintOutline.setTypeface(typeFace);
// 获取输出格式索引
int index = mThemeRadioGroup.indexOfChild(mThemeRadioGroup.findViewById(mThemeRadioGroup.getCheckedRadioButtonId()));
ThemeColor themeColor = mThemeColors.get(index);
mPaintColor = themeColor.getPaintColors();
mPaintHLColor = themeColor.getPaintHLColors();
//
TreeMap<Integer, LyricsLineInfo> lyricsLineInfos = mLyricsReader.getLrcLineInfos();
if (lyricsLineInfos == null) {
Toast.makeText(getApplicationContext(), "歌词内容为空,生成失败!", Toast.LENGTH_SHORT).show();
return;
}
//
mMaxProgress = mLyricsReader.getLyricsInfo().getTotal();
if (mMaxProgress == 0) {
if (mLyricsReader.getLyricsType() == LyricsInfo.LRC) {
Toast.makeText(getApplicationContext(), "歌词内容中不含有歌曲总时长信息([total]标签),不支持生成!", Toast.LENGTH_SHORT).show();
return;
} else {
mMaxProgress = lyricsLineInfos.get(lyricsLineInfos.size() - 1).getEndTime();
}
}
mOutputLrcType = -1;
// 获取输出歌词格式类型
int outputLrcTypeIndex = mOutputLrcTypeRadioGroup.indexOfChild(mOutputLrcTypeRadioGroup.findViewById(outputLrcTypeRadioButtonId));
if (outputLrcTypeIndex == 0) {
mOutputLrcType = -1;
} else if (outputLrcTypeIndex == 1) {
mOutputLrcType = 1;
} else {
mOutputLrcType = 0;
}
mLrcFileParentPath = lrcFile.getParent();
mLrcFileName = lrcFile.getName();
// 每1ms播放进度
mPlayRate = 10;
logger.e("mMaxProgress=" + mMaxProgress);
mHelper.showLoading("正在生成,请稍等...");
long startTime = System.currentTimeMillis();
logger.e("startTime=" + startTime);
Intent intent = new Intent(getApplicationContext(), CreateLrcImageIntentService.clreplaced);
intent.putExtra("startProgressIndex", 0);
intent.putExtra("endProgressIndex", mMaxProgress);
intent.putExtra("startTime", startTime);
startService(intent);
CreateLrcImageIntentService.setUpdateUI(new CreateLrcImageIntentService.UpdateUI() {
@Override
public void refreshLoadingText(String text) {
mHelper.refreshLoadingText(text);
}
@Override
public void finish() {
mHandler.sendEmptyMessage(CREATELRCIMAGEFINISH);
}
@Override
public void loge(String e) {
logger.e(e);
}
});
}
}
19
Source : IconFontDescriptorWrapper.java
with GNU General Public License v3.0
from zeevy
with GNU General Public License v3.0
from zeevy
public clreplaced IconFontDescriptorWrapper {
private final IconFontDescriptor iconFontDescriptor;
private final Map<String, Icon> iconsByKey;
private Typeface cachedTypeface;
public IconFontDescriptorWrapper(IconFontDescriptor iconFontDescriptor) {
this.iconFontDescriptor = iconFontDescriptor;
iconsByKey = new HashMap<String, Icon>();
Icon[] characters = iconFontDescriptor.characters();
for (int i = 0, charactersLength = characters.length; i < charactersLength; i++) {
Icon icon = characters[i];
iconsByKey.put(icon.key(), icon);
}
}
public Icon getIcon(String key) {
return iconsByKey.get(key);
}
public IconFontDescriptor getIconFontDescriptor() {
return iconFontDescriptor;
}
public Typeface getTypeface(Context context) {
if (cachedTypeface != null)
return cachedTypeface;
synchronized (this) {
if (cachedTypeface != null)
return cachedTypeface;
cachedTypeface = Typeface.createFromreplacedet(context.getreplacedets(), iconFontDescriptor.ttfFileName());
return cachedTypeface;
}
}
public boolean hasIcon(Icon icon) {
return iconsByKey.values().contains(icon);
}
}
19
Source : CustomTypefaceSpan.java
with GNU General Public License v3.0
from zeevy
with GNU General Public License v3.0
from zeevy
public clreplaced CustomTypefaceSpan extends ReplacementSpan {
private static final int ROTATION_DURATION = 2000;
private static final Rect TEXT_BOUNDS = new Rect();
private static final Paint LOCAL_PAINT = new Paint();
private static final float BASELINE_RATIO = 1 / 7f;
private final String icon;
private final Typeface type;
private final float iconSizePx;
private final float iconSizeRatio;
private final int iconColor;
private final boolean rotate;
private final boolean baselineAligned;
private final long rotationStartTime;
public CustomTypefaceSpan(Icon icon, Typeface type, float iconSizePx, float iconSizeRatio, int iconColor, boolean rotate, boolean baselineAligned) {
this.rotate = rotate;
this.baselineAligned = baselineAligned;
this.icon = String.valueOf(icon.character());
this.type = type;
this.iconSizePx = iconSizePx;
this.iconSizeRatio = iconSizeRatio;
this.iconColor = iconColor;
this.rotationStartTime = System.currentTimeMillis();
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
LOCAL_PAINT.set(paint);
applyCustomTypeFace(LOCAL_PAINT, type);
LOCAL_PAINT.getTextBounds(icon, 0, 1, TEXT_BOUNDS);
if (fm != null) {
float baselineRatio = baselineAligned ? 0 : BASELINE_RATIO;
fm.descent = (int) (TEXT_BOUNDS.height() * baselineRatio);
fm.ascent = -(TEXT_BOUNDS.height() - fm.descent);
fm.top = fm.ascent;
fm.bottom = fm.descent;
}
return TEXT_BOUNDS.width();
}
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
applyCustomTypeFace(paint, type);
paint.getTextBounds(icon, 0, 1, TEXT_BOUNDS);
canvas.save();
float baselineRatio = baselineAligned ? 0f : BASELINE_RATIO;
if (rotate) {
float rotation = (System.currentTimeMillis() - rotationStartTime) / (float) ROTATION_DURATION * 360f;
float centerX = x + TEXT_BOUNDS.width() / 2f;
float centerY = y - TEXT_BOUNDS.height() / 2f + TEXT_BOUNDS.height() * baselineRatio;
canvas.rotate(rotation, centerX, centerY);
}
canvas.drawText(icon, x - TEXT_BOUNDS.left, y - TEXT_BOUNDS.bottom + TEXT_BOUNDS.height() * baselineRatio, paint);
canvas.restore();
}
public boolean isAnimated() {
return rotate;
}
private void applyCustomTypeFace(Paint paint, Typeface tf) {
paint.setFakeBoldText(false);
paint.setTextSkewX(0f);
paint.setTypeface(tf);
if (rotate)
paint.clearShadowLayer();
if (iconSizeRatio > 0)
paint.setTextSize(paint.getTextSize() * iconSizeRatio);
else if (iconSizePx > 0)
paint.setTextSize(iconSizePx);
if (iconColor < Integer.MAX_VALUE)
paint.setColor(iconColor);
}
}
19
Source : CustomTypefaceSpan.java
with GNU General Public License v3.0
from zeevy
with GNU General Public License v3.0
from zeevy
private void applyCustomTypeFace(Paint paint, Typeface tf) {
paint.setFakeBoldText(false);
paint.setTextSkewX(0f);
paint.setTypeface(tf);
if (rotate)
paint.clearShadowLayer();
if (iconSizeRatio > 0)
paint.setTextSize(paint.getTextSize() * iconSizeRatio);
else if (iconSizePx > 0)
paint.setTextSize(iconSizePx);
if (iconColor < Integer.MAX_VALUE)
paint.setColor(iconColor);
}
19
Source : PagerSlidingTabStrip.java
with GNU General Public License v3.0
from z-chu
with GNU General Public License v3.0
from z-chu
public clreplaced PagerSlidingTabStrip extends HorizontalScrollView {
public interface IconTabProvider {
public int getPageIconResId(int position);
}
// @formatter:off
private static final int[] ATTRS = new int[] { android.R.attr.textSize, android.R.attr.textColor };
// @formatter:on
private LinearLayout.LayoutParams defaultTabLayoutParams;
private LinearLayout.LayoutParams expandedTabLayoutParams;
private final PageListener pageListener = new PageListener();
public OnPageChangeListener delegatePageListener;
private LinearLayout tabsContainer;
private ViewPager pager;
private int tabCount;
private int currentPosition = 0;
private float currentPositionOffset = 0f;
private Paint rectPaint;
private Paint dividerPaint;
private int indicatorColor = 0xFF666666;
private int underlineColor = 0x1A000000;
private int dividerColor = 0x1A000000;
private boolean shouldExpand = false;
private boolean textAllCaps = true;
private int scrollOffset = 52;
private int indicatorHeight = 8;
private int underlineHeight = 0;
private int dividerPadding = 12;
private int tabPadding = 16;
private int dividerWidth = 1;
private int wrapAddWidth = 0;
private boolean indicatorWrapContent = false;
private int tabTextSize = 14;
private int tabSelectTextColor = 0xFF666666;
private int tabUnSelectTextColor = 0xFF666666;
private Typeface tabTypeface = null;
private int tabTypefaceStyle = Typeface.NORMAL;
private int lastScrollX = 0;
private int tabBackgroundResId = -1;
private boolean tabClickble = true;
// Save the selected index
private int pageSelected;
private Locale locale;
public PagerSlidingTabStrip(Context context) {
this(context, null);
}
public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setFillViewport(true);
setWillNotDraw(false);
tabsContainer = new LinearLayout(context);
tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
addView(tabsContainer);
DisplayMetrics dm = getResources().getDisplayMetrics();
scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);
// get system attrs (android:textSize and android:textColor)
TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
// tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
// tabTextColor = a.getColor(1, tabTextColor);
a.recycle();
// get custom attrs
a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight);
underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight);
dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding);
tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);
shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
indicatorWrapContent = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsIndicatorWrap, indicatorWrapContent);
wrapAddWidth = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStrip_pstsIndicatorWrapAddWidht, wrapAddWidth);
tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTextSize, tabTextSize);
tabSelectTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsSelectedTextColor, tabSelectTextColor);
tabUnSelectTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTextColor, tabUnSelectTextColor);
a.recycle();
rectPaint = new Paint();
rectPaint.setAntiAlias(true);
rectPaint.setStyle(Style.FILL);
dividerPaint = new Paint();
dividerPaint.setAntiAlias(true);
dividerPaint.setStrokeWidth(dividerWidth);
defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
if (locale == null) {
locale = getResources().getConfiguration().locale;
}
}
public void setViewPager(ViewPager pager) {
this.pager = pager;
if (pager.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
pager.setOnPageChangeListener(pageListener);
notifyDataSetChanged();
}
public void setOnPageChangeListener(OnPageChangeListener listener) {
this.delegatePageListener = listener;
}
public void notifyDataSetChanged() {
tabsContainer.removeAllViews();
tabCount = pager.getAdapter().getCount();
for (int i = 0; i < tabCount; i++) {
if (pager.getAdapter() instanceof IconTabProvider) {
addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
} else {
addTextTab(i, pager.getAdapter().getPagereplacedle(i).toString());
}
}
updateTabStyles();
getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
currentPosition = pager.getCurrenreplacedem();
scrollToChild(currentPosition, 0);
}
});
}
private void addTextTab(final int position, String replacedle) {
TextView tab = new AppCompatTextView(getContext());
tab.setText(replacedle);
tab.setGravity(Gravity.CENTER);
tab.setSingleLine();
addTab(position, tab);
}
private void addIconTab(final int position, int resId) {
ImageButton tab = new AppCompatImageButton(getContext());
tab.setImageResource(resId);
addTab(position, tab);
}
private void addTab(final int position, View tab) {
tab.setFocusable(true);
tab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (tabClickble) {
pager.setCurrenreplacedem(position);
}
}
});
tab.setPadding(tabPadding, 0, tabPadding, 0);
tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}
private void updateTabStyles() {
for (int i = 0; i < tabCount; i++) {
View v = tabsContainer.getChildAt(i);
if (tabBackgroundResId != -1) {
// v.setBackgroundResource(tabBackgroundResId);
v.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), tabBackgroundResId));
}
if (v instanceof TextView) {
TextView tab = (TextView) v;
tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
tab.setTypeface(tabTypeface, tabTypefaceStyle);
if (pager.getCurrenreplacedem() == i) {
pageSelected = i;
tab.setTextColor(tabSelectTextColor);
} else {
tab.setTextColor(tabUnSelectTextColor);
}
// setAllCaps() is only available from API 14, so the upper case
// is made manually if we are on a
// pre-ICS-build
if (textAllCaps) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
tab.setAllCaps(true);
} else {
tab.setText(tab.getText().toString().toUpperCase(locale));
}
}
}
}
}
private void scrollToChild(int position, int offset) {
if (tabCount == 0) {
return;
}
int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
if (position > 0 || offset > 0) {
newScrollX -= scrollOffset;
}
if (newScrollX != lastScrollX) {
lastScrollX = newScrollX;
scrollTo(newScrollX, 0);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || tabCount == 0) {
return;
}
final int height = getHeight();
// draw indicator line
rectPaint.setColor(indicatorColor);
// default: line below current tab
View currentTab = tabsContainer.getChildAt(currentPosition);
float textViewContentWidth = getTextViewContentWidth((TextView) currentTab);
int indicatorSpac = (int) ((TextView) currentTab).getWidth();
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
// if there is an offset, start interpolating left and right coordinates
// between current and next tab
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
View nextTab = tabsContainer.getChildAt(currentPosition + 1);
textViewContentWidth = getTextViewContentWidth((TextView) currentTab);
indicatorSpac = (int) ((TextView) currentTab).getWidth();
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}
if (indicatorWrapContent) {
canvas.drawRect(lineLeft - wrapAddWidth + getPaddingLeft() + (indicatorSpac - textViewContentWidth) / 2, height - indicatorHeight, lineRight + getPaddingLeft() - (indicatorSpac - textViewContentWidth) / 2 + wrapAddWidth, height, rectPaint);
} else {
canvas.drawRect(lineLeft + getPaddingLeft(), height - indicatorHeight, lineRight + getPaddingLeft(), height, rectPaint);
}
// draw underline
rectPaint.setColor(underlineColor);
canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
// draw divider
dividerPaint.setColor(dividerColor);
for (int i = 0; i < tabCount - 1; i++) {
View tab = tabsContainer.getChildAt(i);
canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
}
}
/**
* z.chu
* @param tv
* @return textview contentwidth
*/
public float getTextViewContentWidth(TextView tv) {
TextPaint textPaint = tv.getPaint();
return textPaint.measureText(tv.getText() + "");
}
private clreplaced PageListener implements OnPageChangeListener {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
currentPosition = position;
currentPositionOffset = positionOffset;
scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth()));
invalidate();
if (delegatePageListener != null) {
delegatePageListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
}
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE) {
scrollToChild(pager.getCurrenreplacedem(), 0);
}
if (delegatePageListener != null) {
delegatePageListener.onPageScrollStateChanged(state);
}
}
@Override
public void onPageSelected(int position) {
if (delegatePageListener != null) {
delegatePageListener.onPageSelected(position);
}
((TextView) tabsContainer.getChildAt(position)).setTextColor(tabSelectTextColor);
((TextView) tabsContainer.getChildAt(pageSelected)).setTextColor(tabUnSelectTextColor);
pageSelected = position;
}
}
public void setIndicatorColor(int indicatorColor) {
this.indicatorColor = indicatorColor;
invalidate();
}
public void setIndicatorColorResource(int resId) {
this.indicatorColor = getResources().getColor(resId);
invalidate();
}
public int getIndicatorColor() {
return this.indicatorColor;
}
public void setIndicatorHeight(int indicatorLineHeightPx) {
this.indicatorHeight = indicatorLineHeightPx;
invalidate();
}
public int getIndicatorHeight() {
return indicatorHeight;
}
public void setUnderlineColor(int underlineColor) {
this.underlineColor = underlineColor;
invalidate();
}
public void setUnderlineColorResource(int resId) {
this.underlineColor = getResources().getColor(resId);
invalidate();
}
public int getUnderlineColor() {
return underlineColor;
}
public void setDividerColor(int dividerColor) {
this.dividerColor = dividerColor;
invalidate();
}
public void setDividerColorResource(int resId) {
this.dividerColor = getResources().getColor(resId);
invalidate();
}
public int getDividerColor() {
return dividerColor;
}
public void setUnderlineHeight(int underlineHeightPx) {
this.underlineHeight = underlineHeightPx;
invalidate();
}
public int getUnderlineHeight() {
return underlineHeight;
}
public void setDividerPadding(int dividerPaddingPx) {
this.dividerPadding = dividerPaddingPx;
invalidate();
}
public int getDividerPadding() {
return dividerPadding;
}
public void setScrollOffset(int scrollOffsetPx) {
this.scrollOffset = scrollOffsetPx;
invalidate();
}
public int getScrollOffset() {
return scrollOffset;
}
public void setShouldExpand(boolean shouldExpand) {
this.shouldExpand = shouldExpand;
requestLayout();
}
public boolean getShouldExpand() {
return shouldExpand;
}
public boolean isTextAllCaps() {
return textAllCaps;
}
public void setAllCaps(boolean textAllCaps) {
this.textAllCaps = textAllCaps;
}
public void setTextSize(int textSizePx) {
this.tabTextSize = textSizePx;
updateTabStyles();
}
public int getTextSize() {
return tabTextSize;
}
public void setUnSelectTextColor(int textColor) {
this.tabUnSelectTextColor = textColor;
updateTabStyles();
}
public void setUnSelectTextColorResource(int resId) {
this.tabUnSelectTextColor = getResources().getColor(resId);
updateTabStyles();
}
public int getUnSelectTextColor() {
return tabUnSelectTextColor;
}
public void setSelectTextColor(int textColor) {
this.tabSelectTextColor = textColor;
updateTabStyles();
}
public void setSelectTextColorResource(int resId) {
this.tabSelectTextColor = getResources().getColor(resId);
updateTabStyles();
}
public int getSelectTextColor() {
return tabSelectTextColor;
}
public void setTypeface(Typeface typeface, int style) {
this.tabTypeface = typeface;
this.tabTypefaceStyle = style;
updateTabStyles();
}
public void setTabBackground(int resId) {
this.tabBackgroundResId = resId;
}
public int getTabBackground() {
return tabBackgroundResId;
}
public void setTabPaddingLeftRight(int paddingPx) {
this.tabPadding = paddingPx;
updateTabStyles();
}
public int getTabPaddingLeftRight() {
return tabPadding;
}
public void setTabClickble(boolean tabClickble) {
this.tabClickble = tabClickble;
}
@Override
public void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
currentPosition = savedState.currentPosition;
requestLayout();
}
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState savedState = new SavedState(superState);
savedState.currentPosition = currentPosition;
return savedState;
}
static clreplaced SavedState extends BaseSavedState {
int currentPosition;
public SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {
super(in);
currentPosition = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(currentPosition);
}
public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
}
19
Source : PagerSlidingTabStrip.java
with GNU General Public License v3.0
from z-chu
with GNU General Public License v3.0
from z-chu
public void setTypeface(Typeface typeface, int style) {
this.tabTypeface = typeface;
this.tabTypefaceStyle = style;
updateTabStyles();
}
19
Source : FontCache.java
with GNU General Public License v3.0
from ywwynm
with GNU General Public License v3.0
from ywwynm
public static Typeface get(String name, Context context) {
Typeface tf = fontCache.get(name);
if (tf == null) {
tf = Typeface.createFromreplacedet(context.getreplacedets(), name);
fontCache.put(name, tf);
}
return tf;
}
19
Source : FontPopup.java
with Apache License 2.0
from yuyangXu0222
with Apache License 2.0
from yuyangXu0222
private void getFontFromreplacedets() {
mTypefaceList.add(Typeface.DEFAULT);
String[] fontNameList = null;
replacedetManager replacedetManager = mContext.getreplacedets();
try {
fontNameList = replacedetManager.list(FONTS);
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < fontNameList.length; i++) {
String fontPath = FONTS + "/" + fontNameList[i];
// 根据路径得到Typeface
Typeface typeface = Typeface.createFromreplacedet(replacedetManager, fontPath);
mTypefaceList.add(typeface);
}
}
19
Source : BookPageFactory.java
with Apache License 2.0
from yuyangXu0222
with Apache License 2.0
from yuyangXu0222
private void getFontFromreplacedets() {
mTypefaceList.add(Typeface.DEFAULT);
String[] fontNameList = null;
replacedetManager replacedetManager = mContext.getreplacedets();
try {
fontNameList = replacedetManager.list(FontPopup.FONTS);
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < fontNameList.length; i++) {
String fontPath = FontPopup.FONTS + "/" + fontNameList[i];
// 根据路径得到Typeface
Typeface typeface = Typeface.createFromreplacedet(replacedetManager, fontPath);
mTypefaceList.add(typeface);
}
}
19
Source : AddItemActivity.java
with GNU General Public License v3.0
from yuukidach
with GNU General Public License v3.0
from yuukidach
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_item);
addCostBtn = (Button) findViewById(R.id.add_cost_button);
addEarnBtn = (Button) findViewById(R.id.add_earn_button);
addFinishBtn = (ImageButton) findViewById(R.id.add_finish);
addDescription = (ImageButton) findViewById(R.id.add_description);
clearBtn = (Button) findViewById(R.id.clear);
words = (TextView) findViewById(R.id.anime_words);
// 设置字体颜色
Typeface typeface = Typeface.createFromreplacedet(getreplacedets(), "fonts/chinese_character.ttf");
clearBtn.setTypeface(typeface);
words.setTypeface(typeface);
// 设置按钮监听
addCostBtn.setOnClickListener(new ButtonListener());
addEarnBtn.setOnClickListener(new ButtonListener());
addFinishBtn.setOnClickListener(new ButtonListener());
addDescription.setOnClickListener(new ButtonListener());
clearBtn.setOnClickListener(new ButtonListener());
bannerText = (TextView) findViewById(R.id.chosen_replacedle);
bannerImage = (ImageView) findViewById(R.id.chosen_image);
moneyText = (TextView) findViewById(R.id.input_money_text);
// 及时清零
moneyText.setText("0.00");
manager = getSupportFragmentManager();
transaction = manager.beginTransaction();
transaction.replace(R.id.item_fragment, new CostFragment());
transaction.commit();
}
19
Source : MainActivity.java
with GNU General Public License v3.0
from yusufcakal
with GNU General Public License v3.0
from yusufcakal
public clreplaced MainActivity extends Activity implements View.OnClickListener {
private Typeface tfBold, tfRegular;
private FlatButton btnStaff, btnOrder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tfBold = Typeface.createFromreplacedet(getreplacedets(), "fonts/lato/Lato-Bold.ttf");
tfRegular = Typeface.createFromreplacedet(getreplacedets(), "fonts/lato/Lato-Regular.ttf");
btnStaff = (FlatButton) findViewById(R.id.btnStaff);
btnOrder = (FlatButton) findViewById(R.id.btnOrder);
btnStaff.setOnClickListener(this);
btnOrder.setOnClickListener(this);
btnStaff.setTypeface(tfRegular);
btnOrder.setTypeface(tfRegular);
}
@Override
public void onClick(View v) {
if (v.equals(btnStaff)) {
startActivity(new Intent(this, StaffLoginActivity.clreplaced));
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
} else if (v.equals(btnOrder)) {
// Intent ıntent = new Intent(this, CamActivity.clreplaced);
// startActivity(ıntent);
startActivity(new Intent(getApplicationContext(), UserActivity.clreplaced));
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
SharedPreferences sharedpreferences = getSharedPreferences("userBasket", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean("user", true);
editor.commit();
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
// TODO:App is finish
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
19
Source : MenuActivity.java
with MIT License
from YuriiSalimov
with MIT License
from YuriiSalimov
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_replacedLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_menu);
replacedetManager replacedetManager = getreplacedets();
sound = new Sound(replacedetManager);
setButtonSound = sound.loadSound("Schelchok1.mp3");
sound.setCheckSound(true);
Typeface digitalFont = Typeface.createFromreplacedet(this.getreplacedets(), "font.ttf");
Button bGame = (Button) findViewById(R.id.bNewGame);
bGame.setTypeface(digitalFont);
bGame.setOnClickListener(onClickListener);
Button bСontinue = (Button) findViewById(R.id.bСontinue);
bСontinue.setTypeface(digitalFont);
bСontinue.setOnClickListener(onClickListener);
Button bHelp = (Button) findViewById(R.id.bHelp);
bHelp.setTypeface(digitalFont);
bHelp.setOnClickListener(onClickListener);
Button bExit = (Button) findViewById(R.id.bExit);
bExit.setTypeface(digitalFont);
bExit.setOnClickListener(onClickListener);
try {
sound.setCheckSound(getIntent().getExtras().getBoolean("checkSound"));
} catch (Exception e) {
sound.setCheckSound(true);
}
bSound = (ImageButton) this.findViewById(R.id.bSoundOffOn);
bSound.setOnClickListener(onClickListener);
if (sound.getCheckSound())
bSound.setImageResource(R.drawable.soundon);
else
bSound.setImageResource(R.drawable.soundoff);
TextView tGame = (TextView) findViewById(R.id.tGame);
tGame.setTypeface(digitalFont);
}
19
Source : LevelActivity.java
with MIT License
from YuriiSalimov
with MIT License
from YuriiSalimov
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_replacedLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_level);
replacedetManager replacedetManager = getreplacedets();
sound = new Sound(replacedetManager);
setButtonSound = sound.loadSound("Schelchok1.mp3");
sound.setCheckSound(true);
Typeface digitalFont = Typeface.createFromreplacedet(this.getreplacedets(), "font.ttf");
ImageButton bNewGame9 = (ImageButton) findViewById(R.id.bLevel9);
bNewGame9.setOnClickListener(onClickListener);
ImageButton bNewGame15 = (ImageButton) findViewById(R.id.bLevel24);
bNewGame15.setOnClickListener(onClickListener);
ImageButton bNewGame24 = (ImageButton) findViewById(R.id.bLevel15);
bNewGame24.setOnClickListener(onClickListener);
try {
sound.setCheckSound(getIntent().getExtras().getBoolean("checkSound"));
} catch (Exception e) {
sound.setCheckSound(true);
}
bSound = (ImageButton) this.findViewById(R.id.bSoundOffOn);
bSound.setOnClickListener(onClickListener);
if (sound.getCheckSound())
bSound.setImageResource(R.drawable.soundon);
else
bSound.setImageResource(R.drawable.soundoff);
ImageButton bBackMenu = (ImageButton) this.findViewById(R.id.bBackMenu);
bBackMenu.setOnClickListener(onClickListener);
TextView tGame = (TextView) findViewById(R.id.tGame);
tGame.setTypeface(digitalFont);
}
19
Source : HelpActivity.java
with MIT License
from YuriiSalimov
with MIT License
from YuriiSalimov
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_replacedLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_help);
Typeface digitalFont = Typeface.createFromreplacedet(this.getreplacedets(), "font.ttf");
Button bMenu = (Button) findViewById(R.id.bMenu);
bMenu.setTypeface(digitalFont);
bMenu.setOnClickListener(onClickListener);
TextView tAbout = (TextView) findViewById(R.id.tAbout);
tAbout.setTypeface(digitalFont);
replacedetManager replacedetManager = getreplacedets();
sound = new Sound(replacedetManager);
setButtonSound = sound.loadSound("Schelchok1.mp3");
try {
sound.setCheckSound(getIntent().getExtras().getBoolean("checkSound"));
} catch (Exception e) {
sound.setCheckSound(true);
}
}
19
Source : GameActivity9.java
with MIT License
from YuriiSalimov
with MIT License
from YuriiSalimov
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_replacedLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_game9);
button = new ImageButton[N][N];
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
button[i][j] = (ImageButton) this.findViewById(BUTTON_ID[i][j]);
button[i][j].setOnClickListener(onClickListener);
}
ImageButton bNewGame = (ImageButton) this.findViewById(R.id.bNewGame);
bNewGame.setOnClickListener(onClickListener);
ImageButton bBackMenu = (ImageButton) this.findViewById(R.id.bBackMenu);
bBackMenu.setOnClickListener(onClickListener);
ImageButton bAbout = (ImageButton) this.findViewById(R.id.bAboutGame);
bAbout.setOnClickListener(onClickListener);
ibSound = (ImageButton) this.findViewById(R.id.bSoundOffOn);
ibSound.setOnClickListener(onClickListener);
Typeface digitalFont = Typeface.createFromreplacedet(this.getreplacedets(), "font.ttf");
TextView tPyatnashki = (TextView) this.findViewById(R.id.tPyatnashki);
tPyatnashki.setTypeface(digitalFont);
TextView tSScore = (TextView) this.findViewById(R.id.tSScore);
tSScore.setTypeface(digitalFont);
tScore = (TextView) this.findViewById(R.id.tScore);
tScore.setTypeface(digitalFont);
TextView tBestSScore = (TextView) this.findViewById(R.id.tBestSScore);
tBestSScore.setTypeface(digitalFont);
tBestScore = (TextView) this.findViewById(R.id.tBestScore);
tBestScore.setTypeface(digitalFont);
replacedetManager AM = getreplacedets();
sound = new Sound(AM);
clickSound = sound.loadSound("Schelchok.mp3");
victorySound = sound.loadSound("Victory.mp3");
setButtonSound = sound.loadSound("Schelchok1.mp3");
try {
sound.setCheckSound(getIntent().getExtras().getBoolean("checkSound"));
} catch (Exception e) {
sound.setCheckSound(true);
}
cards = new Cards(N, N);
try {
if (getIntent().getExtras().getInt("keyGame") == 1) {
continueGame();
checkFinish();
} else
newGame();
} catch (Exception e) {
newGame();
}
}
19
Source : GameActivity24.java
with MIT License
from YuriiSalimov
with MIT License
from YuriiSalimov
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_replacedLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_game24);
button = new ImageButton[N][N];
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
button[i][j] = (ImageButton) this.findViewById(BUT_ID[i][j]);
button[i][j].setOnClickListener(onClickListener);
}
ImageButton bNewGame = (ImageButton) this.findViewById(R.id.bNewGame);
bNewGame.setOnClickListener(onClickListener);
ImageButton bBackMenu = (ImageButton) this.findViewById(R.id.bBackMenu);
bBackMenu.setOnClickListener(onClickListener);
ImageButton bAbout = (ImageButton) this.findViewById(R.id.bAboutGame);
bAbout.setOnClickListener(onClickListener);
ibSound = (ImageButton) this.findViewById(R.id.bSoundOffOn);
ibSound.setOnClickListener(onClickListener);
Typeface digitalFont = Typeface.createFromreplacedet(this.getreplacedets(), "font.ttf");
TextView tPyatnashki = (TextView) this.findViewById(R.id.tPyatnashki);
tPyatnashki.setTypeface(digitalFont);
TextView tSScore = (TextView) this.findViewById(R.id.tSScore);
tSScore.setTypeface(digitalFont);
tScore = (TextView) this.findViewById(R.id.tScore);
tScore.setTypeface(digitalFont);
TextView tBestSScore = (TextView) this.findViewById(R.id.tBestSScore);
tBestSScore.setTypeface(digitalFont);
tBestScore = (TextView) this.findViewById(R.id.tBestScore);
tBestScore.setTypeface(digitalFont);
replacedetManager AM = getreplacedets();
sound = new Sound(AM);
clickSound = sound.loadSound("Schelchok.mp3");
victorySound = sound.loadSound("Victory.mp3");
setButtonSound = sound.loadSound("Schelchok1.mp3");
try {
sound.setCheckSound(getIntent().getExtras().getBoolean("checkSound"));
} catch (Exception e) {
sound.setCheckSound(true);
}
cards = new Cards(N, N);
try {
if (getIntent().getExtras().getInt("keyGame") == 1) {
continueGame();
checkFinish();
} else
newGame();
} catch (Exception e) {
newGame();
}
}
19
Source : GameActivity.java
with MIT License
from YuriiSalimov
with MIT License
from YuriiSalimov
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_replacedLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_game);
button = new ImageButton[N][N];
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
button[i][j] = (ImageButton) this.findViewById(BUTTON_ID[i][j]);
button[i][j].setOnClickListener(onClickListener);
}
ImageButton bNewGame = (ImageButton) this.findViewById(R.id.bNewGame);
bNewGame.setOnClickListener(onClickListener);
ImageButton bBackMenu = (ImageButton) this.findViewById(R.id.bBackMenu);
bBackMenu.setOnClickListener(onClickListener);
ImageButton bAbout = (ImageButton) this.findViewById(R.id.bAboutGame);
bAbout.setOnClickListener(onClickListener);
ibSound = (ImageButton) this.findViewById(R.id.bSoundOffOn);
ibSound.setOnClickListener(onClickListener);
Typeface digitalFont = Typeface.createFromreplacedet(this.getreplacedets(), "font.ttf");
TextView tPyatnashki = (TextView) this.findViewById(R.id.tPyatnashki);
tPyatnashki.setTypeface(digitalFont);
TextView tSScore = (TextView) this.findViewById(R.id.tSScore);
tSScore.setTypeface(digitalFont);
tScore = (TextView) this.findViewById(R.id.tScore);
tScore.setTypeface(digitalFont);
TextView tBestSScore = (TextView) this.findViewById(R.id.tBestSScore);
tBestSScore.setTypeface(digitalFont);
tBestScore = (TextView) this.findViewById(R.id.tBestScore);
tBestScore.setTypeface(digitalFont);
replacedetManager AM = getreplacedets();
sound = new Sound(AM);
clickSound = sound.loadSound("Schelchok.mp3");
victorySound = sound.loadSound("Victory.mp3");
setButtonSound = sound.loadSound("Schelchok1.mp3");
try {
sound.setCheckSound(getIntent().getExtras().getBoolean("checkSound"));
} catch (Exception e) {
sound.setCheckSound(true);
}
cards = new Cards(N, N);
try {
if (getIntent().getExtras().getInt("keyGame") == 1) {
continueGame();
checkFinish();
} else
newGame();
} catch (Exception e) {
newGame();
}
}
19
Source : CustomTextView.java
with BSD 3-Clause "New" or "Revised" License
from YUNEEC
with BSD 3-Clause "New" or "Revised" License
from YUNEEC
public void init() {
Typeface tf = Typeface.createFromreplacedet(getContext().getreplacedets(), "font/Lato-Regular.ttf");
setTypeface(tf, 1);
}
19
Source : CustomButton.java
with BSD 3-Clause "New" or "Revised" License
from YUNEEC
with BSD 3-Clause "New" or "Revised" License
from YUNEEC
public void init() {
Typeface tf = Typeface.createFromreplacedet(getContext().getreplacedets(), "font/Lato-Regular.ttf");
setTypeface(tf, 0);
}
19
Source : ModeSelectorItem.java
with Apache License 2.0
from Yuloran
with Apache License 2.0
from Yuloran
@Override
public void onFinishInflate() {
mIcon = (ModeIconView) findViewById(R.id.selector_icon);
mText = (TextView) findViewById(R.id.selector_text);
Typeface typeface;
if (ApiHelper.HAS_ROBOTO_MEDIUM_FONT) {
typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL);
} else {
// Load roboto_light typeface from replacedets.
typeface = Typeface.createFromreplacedet(getResources().getreplacedets(), "Roboto-Medium.ttf");
}
mText.setTypeface(typeface);
}
19
Source : XViewHolder.java
with Apache License 2.0
from youth5201314
with Apache License 2.0
from youth5201314
public XViewHolder setTypeface(Typeface typeface, @IdRes int... viewIds) {
for (@IdRes int viewId : viewIds) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
return this;
}
19
Source : BaseListHolder.java
with Apache License 2.0
from youlookwhat
with Apache License 2.0
from youlookwhat
/**
* Apply the typeface to the given viewId, and enable subpixel rendering.
*/
public BaseListHolder setTypeface(@IdRes int viewId, Typeface typeface) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
return this;
}
19
Source : BaseListHolder.java
with Apache License 2.0
from youlookwhat
with Apache License 2.0
from youlookwhat
/**
* Apply the typeface to all the given viewIds, and enable subpixel rendering.
*/
public BaseListHolder setTypeface(Typeface typeface, int... viewIds) {
for (int viewId : viewIds) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
return this;
}
19
Source : BaseByViewHolder.java
with Apache License 2.0
from youlookwhat
with Apache License 2.0
from youlookwhat
/**
* Apply the typeface to the given viewId, and enable subpixel rendering.
*/
public BaseByViewHolder setTypeface(@IdRes int viewId, Typeface typeface) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
return this;
}
19
Source : BaseByViewHolder.java
with Apache License 2.0
from youlookwhat
with Apache License 2.0
from youlookwhat
/**
* Apply the typeface to all the given viewIds, and enable subpixel rendering.
*/
public BaseByViewHolder setTypeface(Typeface typeface, int... viewIds) {
for (int viewId : viewIds) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
return this;
}
19
Source : FontUtil.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
public static String getName(@NonNull Typeface typeface) {
for (Map.Entry<String, Typeface> entry : sTypefaceCache.entrySet()) {
if (entry.getValue() == typeface) {
return entry.getKey();
}
}
return null;
}
19
Source : FontUtil.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
public static Typeface get(Context context, String font) {
synchronized (sTypefaceCache) {
if (!sTypefaceCache.containsKey(font)) {
Typeface tf = Typeface.createFromreplacedet(context.getApplicationContext().getreplacedets(), "fonts/" + font + ".ttf");
sTypefaceCache.put(font, tf);
}
return sTypefaceCache.get(font);
}
}
19
Source : CollapsingTextHelper.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
public void setTypeface(Typeface typeface) {
if (typeface == null) {
typeface = Typeface.DEFAULT;
}
if (mTextPaint.getTypeface() != typeface) {
mTextPaint.setTypeface(typeface);
recalculate();
}
}
19
Source : FabOverlapTextView.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
public void setTypeface(Typeface typeface) {
paint.setTypeface(typeface);
}
19
Source : LoadingLayoutProxy.java
with Apache License 2.0
from yingLanNull
with Apache License 2.0
from yingLanNull
public void setTextTypeface(Typeface tf) {
for (LoadingLayout layout : mLoadingLayouts) {
layout.setTextTypeface(tf);
}
}
19
Source : LoadingLayout.java
with Apache License 2.0
from yingLanNull
with Apache License 2.0
from yingLanNull
@Override
public void setTextTypeface(Typeface tf) {
mHeaderText.setTypeface(tf);
}
19
Source : FontManager.java
with Apache License 2.0
from yikwing
with Apache License 2.0
from yikwing
public Typeface getFont(String replacedet) {
if (fonts.containsKey(replacedet))
return fonts.get(replacedet);
Typeface font = null;
try {
font = Typeface.createFromreplacedet(replacedetManager, replacedet);
fonts.put(replacedet, font);
} catch (RuntimeException e) {
Log.e(TAG, "getFont: Can't create font from replacedet.", e);
}
return font;
}
19
Source : OutlineTextView.java
with MIT License
from yashketkar
with MIT License
from yashketkar
public void setTypeface(Typeface tf) {
super.setTypeface(tf);
requestLayout();
invalidate();
initPaint();
}
See More Examples