android.graphics.Typeface Java Examples
The following examples show how to use
android.graphics.Typeface.
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: ListWidget.java From commcare-android with Apache License 2.0 | 7 votes |
@Override protected void addQuestionText() { // Add the text view. Textview always exists, regardless of whether there's text. TextView questionText = new TextView(getContext()); setQuestionText(questionText, mPrompt); questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXTSIZE); questionText.setTypeface(null, Typeface.BOLD); questionText.setPadding(0, 0, 0, 7); questionText.setId(buttonIdBase); // assign random id // Wrap to the size of the parent view questionText.setHorizontallyScrolling(false); if (mPrompt.getLongText() == null) { questionText.setVisibility(GONE); } // Put the question text on the left half of the screen LinearLayout.LayoutParams labelParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); labelParams.weight = 1; questionLayout = new LinearLayout(getContext()); questionLayout.setOrientation(LinearLayout.HORIZONTAL); questionLayout.addView(questionText, labelParams); }
Example #2
Source File: DialogUtils.java From io16experiment-master with Apache License 2.0 | 6 votes |
/** * Create a progress dialog for the loading spinner or progress indicator * <p/> * @param activity * @param spinner * @param titleId * @param messageId * @param cancelable * @param max * @param onCancelListener * @param typeface * @param formatArgs * @return */ private static MaterialDialog createProgressDialog(final Activity activity, boolean spinner, int titleId, int messageId, boolean cancelable, int max, DialogInterface.OnCancelListener onCancelListener, Typeface typeface, Object... formatArgs) { MaterialDialog.Builder builder = new MaterialDialog.Builder(activity) .cancelable(cancelable); if (titleId > DEFAULT_TITLE_ID) { builder.title(messageId > DEFAULT_MESSAGE_ID ? activity.getString(titleId) : activity.getString(titleId, formatArgs)); } if (messageId > DEFAULT_MESSAGE_ID) { builder.content(activity.getString(messageId, formatArgs)).typeface(typeface, typeface); } if (onCancelListener != null) { builder.cancelListener(onCancelListener); } if (spinner) { builder.progress(true, 0); } else { builder.progress(false, max, true); } return builder.build(); }
Example #3
Source File: ColorsText.java From JsDroidEditor with Mozilla Public License 2.0 | 6 votes |
private void init() { mNumberPadding = DpiUtils.dip2px(getContext(), 5); mTextPadding = DpiUtils.dip2px(getContext(), 4); mLineNumberBgStrokeWidth = DpiUtils.dip2px(getContext(), 2); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); setLayoutParams(params); setGravity(Gravity.START); // 设值背景透明 setBackgroundColor(Color.TRANSPARENT); // 设值字体大小 setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); // 设置字体颜色(透明是为了兼容不能反射绘制光标以及选择文字背景的情况) setTextColor(Color.TRANSPARENT); setTypeface(Typeface.MONOSPACE); setPadding(0, DpiUtils.dip2px(getContext(), 2), DpiUtils.dip2px(getContext(), 8), DpiUtils.dip2px(getContext(), 48)); }
Example #4
Source File: RNTextSizeModule.java From react-native-text-size with BSD 2-Clause "Simplified" License | 6 votes |
/** * https://stackoverflow.com/questions/27631736 * /meaning-of-top-ascent-baseline-descent-bottom-and-leading-in-androids-font */ @SuppressWarnings("unused") @ReactMethod public void fontFromSpecs(@Nullable final ReadableMap specs, final Promise promise) { final RNTextSizeConf conf = getConf(specs, promise); if (conf == null) { return; } final Typeface typeface = RNTextSizeConf.getFont(mReactContext, conf.fontFamily, conf.fontStyle); final TextPaint textPaint = sTextPaintInstance; final int fontSize = (int) Math.ceil(conf.scale(conf.fontSize)); textPaint.reset(); textPaint.setTypeface(typeface); textPaint.setTextSize(fontSize); promise.resolve(fontInfoFromTypeface(textPaint, typeface, conf)); }
Example #5
Source File: TypefaceUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
/** * create typeface * * @param context * @param name * @return */ public static Typeface create( Context context, String name) { Typeface result = SimpleCache.getCache(TAG).get(name); if (result == null) { String fontNameOrAssetPathOrFilePath = ParamUtil.getFileNameWithPostfix(name, "ttf"); result = createFromAsset(context, fontNameOrAssetPathOrFilePath); if (result == null) { result = createFromFile(fontNameOrAssetPathOrFilePath); } if (result == null) { result = createByName(fontNameOrAssetPathOrFilePath); } } SimpleCache.getCache(TAG_TYPEFACE_NAME).put(result, name);//cache name return SimpleCache.getCache(TAG).put(name, result); }
Example #6
Source File: SlidingTabLayout.java From animation-samples with Apache License 2.0 | 6 votes |
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
Example #7
Source File: MergeListAdapter.java From ContactMerger with Apache License 2.0 | 6 votes |
public MergeListAdapter(Activity activity) { super(); model = new ArrayList<MergeContact>(); this.activity = activity; update(); provider = activity.getContentResolver().acquireContentProviderClient( ContactsContract.AUTHORITY_URI); contactMapper = new ContactDataMapper(provider); contactMapper.setCache(new ShiftedExpireLRU(5 * 60 * 1000, 100)); layoutInflater = activity.getLayoutInflater(); font = Typeface.createFromAsset( activity.getAssets(), "fontawesome-webfont.ttf" ); }
Example #8
Source File: SlidingTabView.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title); tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(0xffffffff); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); tab.setTypeface(Typeface.DEFAULT_BOLD); tab.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, 0)); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { didSelectTab(position); } }); addView(tab); LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = 0; layoutParams.weight = 50; tab.setLayoutParams(layoutParams); tabCount++; }
Example #9
Source File: Html.java From EhViewer with Apache License 2.0 | 6 votes |
private static void endHeader(SpannableStringBuilder text) { int len = text.length(); Object obj = getLast(text, Header.class); int where = text.getSpanStart(obj); text.removeSpan(obj); // Back off not to change only the text, not the blank line. while (len > where && text.charAt(len - 1) == '\n') { len--; } if (where != len) { Header h = (Header) obj; text.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); text.setSpan(new StyleSpan(Typeface.BOLD), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }
Example #10
Source File: AccentSwitch.java From holoaccent with Apache License 2.0 | 6 votes |
public void setSwitchTypeface(Typeface tf, int style) { if (style > 0) { if (tf == null) { tf = Typeface.defaultFromStyle(style); } else { tf = Typeface.create(tf, style); } setSwitchTypeface(tf); // now compute what (if any) algorithmic styling is needed int typefaceStyle = tf != null ? tf.getStyle() : 0; int need = style & ~typefaceStyle; mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0); mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0); } else { mTextPaint.setFakeBoldText(false); mTextPaint.setTextSkewX(0); setSwitchTypeface(tf); } }
Example #11
Source File: UIUtils.java From v2ex with Apache License 2.0 | 6 votes |
/** * Given a snippet string with matching segments surrounded by curly * braces, turn those areas into bold spans, removing the curly braces. */ public static Spannable buildStyledSnippet(String snippet) { final SpannableStringBuilder builder = new SpannableStringBuilder(snippet); // Walk through string, inserting bold snippet spans int startIndex, endIndex = -1, delta = 0; while ((startIndex = snippet.indexOf('{', endIndex)) != -1) { endIndex = snippet.indexOf('}', startIndex); // Remove braces from both sides builder.delete(startIndex - delta, startIndex - delta + 1); builder.delete(endIndex - delta - 1, endIndex - delta); // Insert bold style builder.setSpan(new StyleSpan(Typeface.BOLD), startIndex - delta, endIndex - delta - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); //builder.setSpan(new ForegroundColorSpan(0xff111111), // startIndex - delta, endIndex - delta - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); delta += 2; } return builder; }
Example #12
Source File: iOSVolumePanel.java From Noyze with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); Context context = getContext(); LayoutInflater inflater = LayoutInflater.from(context); Typeface helveticaBold = Typeface.createFromAsset(context.getAssets(), "fonts/HelveticaNeue-Bold.ttf"); Typeface helvetica = Typeface.createFromAsset(context.getAssets(), "fonts/HelveticaNeue.ttf"); root = (ViewGroup) inflater.inflate(R.layout.ios_volume_adjust, null); seekBar = (iOSProgressBar) root.findViewById(android.R.id.progress); icon = (ImageView) root.findViewById(R.id.stream_icon); volumeText = (TextView) root.findViewById(R.id.volume_text); silent = (TextView) root.findViewById(R.id.mediaSilent); volumeText.setTypeface(helveticaBold); silent.setTypeface(helvetica); volumeText.setPaintFlags(volumeText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); silent.setPaintFlags(silent.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); // Set the default color & background. if (!has(COLOR)) color = Color.WHITE; if (!has(BACKGROUND)) backgroundColor = Color.BLACK; mLayout = root; }
Example #13
Source File: TextView.java From Genius-Android with Apache License 2.0 | 6 votes |
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) { if (attrs == null) return; final Context context = getContext(); final Resources resources = getResources(); final float density = resources.getDisplayMetrics().density; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextView, defStyleAttr, defStyleRes); int border = a.getInt(R.styleable.TextView_gBorder, 0); int borderSize = a.getDimensionPixelOffset(R.styleable.TextView_gBorderSize, (int) density); int borderColor = a.getColor(R.styleable.TextView_gBorderColor, UiCompat.getColor(resources, R.color.g_default_base_secondary)); String fontFile = a.getString(R.styleable.TextView_gFont); a.recycle(); setBorder(border, borderSize, borderColor); // Check for IDE preview render if (!this.isInEditMode() && fontFile != null && fontFile.length() > 0) { Typeface typeface = Ui.getFont(getContext(), fontFile); if (typeface != null) setTypeface(typeface); } }
Example #14
Source File: MessageAdapter.java From Conversations with GNU General Public License v3.0 | 6 votes |
private void toggleWhisperInfo(ViewHolder viewHolder, final Message message, final boolean darkBackground) { if (message.isPrivateMessage()) { final String privateMarker; if (message.getStatus() <= Message.STATUS_RECEIVED) { privateMarker = activity.getString(R.string.private_message); } else { Jid cp = message.getCounterpart(); privateMarker = activity.getString(R.string.private_message_to, Strings.nullToEmpty(cp == null ? null : cp.getResource())); } final SpannableString body = new SpannableString(privateMarker); body.setSpan(new ForegroundColorSpan(getMessageTextColor(darkBackground, false)), 0, privateMarker.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); body.setSpan(new StyleSpan(Typeface.BOLD), 0, privateMarker.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); viewHolder.messageBody.setText(body); viewHolder.messageBody.setVisibility(View.VISIBLE); } else { viewHolder.messageBody.setVisibility(View.GONE); } }
Example #15
Source File: FontAdapter.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
@Override public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { if (fileList.size() > 0) { Typeface typeface = Typeface.createFromFile(fileList.get(position)); holder.tvFont.setTypeface(typeface); holder.tvFont.setText(fileList.get(position).getName()); if (fileList.get(position).getAbsolutePath().equals(selectPath)) { holder.ivChecked.setVisibility(View.VISIBLE); } else { holder.ivChecked.setVisibility(View.INVISIBLE); } holder.tvFont.setOnClickListener(view -> { if (thisListener != null) { thisListener.setFontPath(fileList.get(position).getAbsolutePath()); } }); } else { holder.tvFont.setText(R.string.fonts_folder); } }
Example #16
Source File: SuggestionStripLayoutHelper.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
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; }
Example #17
Source File: ItemLoanPieChartView.java From loaned-android with Apache License 2.0 | 6 votes |
private void init(Context c){ Log.d(TAG,"Init called"); // Create the colour array mColours = new int[6]; mColours[0] = Color.parseColor("#1bc5a4"); mColours[1] = Color.parseColor("#9b59b6"); mColours[2] = Color.parseColor("#2ecc71"); mColours[3] = Color.parseColor("#e74c3c"); mColours[4] = Color.parseColor("#3498db"); mColours[5] = Color.parseColor("#e67e22"); mCentreCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCentreCirclePaint.setColor(Color.parseColor("#f3f3f3")); mCentreCirclePaint.setStyle(Paint.Style.FILL); mCentreTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCentreTextPaint.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); mCentreTextPaint.setColor(mColours[0]); mCentreTextPaint.setTextAlign(Align.CENTER); mCentreTextPaint.setTextSize(80); mCentreNumberPaint = new Paint(mCentreTextPaint); mCentreNumberPaint.setTextSize(190); mCentreNumberPaint.setColor(c.getResources().getColor(R.color.text_main)); mCentreNumberPaint.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL)); mRect = new RectF(); }
Example #18
Source File: MainActivity.java From journaldev with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_fonts); /*ambleBold=(TextView)findViewById(R.id.ambleBold); ambleLight=(TextView)findViewById(R.id.ambleLight); ambleRegular=(TextView)findViewById(R.id.ambleRegular); openSansRegular=(TextView)findViewById(R.id.opRegular); openSansItalic=(TextView)findViewById(R.id.opItalic);*/ btn=(Button)findViewById(R.id.pacifico); /*ambleBold.setTypeface(Typeface.createFromAsset(getAssets(), A_BOLD)); ambleLight.setTypeface(Typeface.createFromAsset(getAssets(), A_LIGHT)); ambleRegular.setTypeface(Typeface.createFromAsset(getAssets(), A_REGULAR)); openSansRegular.setTypeface(Typeface.createFromAsset(getAssets(), O_REGULAR)); openSansItalic.setTypeface(Typeface.createFromAsset(getAssets(), O_ITALIC));*/ btn.setTypeface(Typeface.createFromAsset(getAssets(), P_REGULAR)); }
Example #19
Source File: EditPage.java From ShareSDKShareDifMsgDemo-Android with MIT License | 6 votes |
private LinearLayout getBodyBottom() { LinearLayout llBottom = new LinearLayout(getContext()); llBottom.setLayoutParams(new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); String platform = String.valueOf(reqData.get("platform")); LinearLayout line = getAtLine(platform); if (line != null) { llBottom.addView(line); } // 字数统计 tvCounter = new TextView(getContext()); tvCounter.setText(String.valueOf(MAX_TEXT_COUNT)); tvCounter.setTextColor(0xffcfcfcf); tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); tvCounter.setTypeface(Typeface.DEFAULT_BOLD); LinearLayout.LayoutParams lpCounter = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpCounter.gravity = Gravity.CENTER_VERTICAL; tvCounter.setLayoutParams(lpCounter); llBottom.addView(tvCounter); return llBottom; }
Example #20
Source File: SlidingTabLayout.java From SlideDayTimePicker with Apache License 2.0 | 6 votes |
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
Example #21
Source File: iOSDialog.java From iOSDialog with MIT License | 6 votes |
public iOSDialog(Context context, String title, String subtitle, boolean bold, Typeface typeFace,boolean cancelable) { negativeExist=false; dialog = new Dialog(context); dialog.setContentView(R.layout.alerts_two_buttons); if(dialog.getWindow()!=null) dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); initViews(); dialog.setCancelable(cancelable); setTitle(title); setSubtitle(subtitle); setBoldPositiveLabel(bold); setTypefaces(typeFace); initEvents(); }
Example #22
Source File: RadialTimePickerView.java From SublimePicker with Apache License 2.0 | 5 votes |
/** * Draw the 12 text values at the positions specified by the textGrid parameters. */ private void drawTextElements(Canvas canvas, float textSize, Typeface typeface, ColorStateList textColor, String[] texts, float[] textX, float[] textY, Paint paint, int alpha, boolean showActivated, int activatedDegrees, boolean activatedOnly) { paint.setTextSize(textSize); paint.setTypeface(typeface); // The activated index can touch a range of elements. final float activatedIndex = activatedDegrees / (360.0f / NUM_POSITIONS); final int activatedFloor = (int) activatedIndex; final int activatedCeil = ((int) Math.ceil(activatedIndex)) % NUM_POSITIONS; for (int i = 0; i < 12; i++) { final boolean activated = (activatedFloor == i || activatedCeil == i); if (activatedOnly && !activated) { continue; } final int stateMask = SUtils.STATE_ENABLED | (showActivated && activated ? SUtils.STATE_ACTIVATED : 0); final int color = textColor.getColorForState(SUtils.resolveStateSet(stateMask), 0); paint.setColor(color); paint.setAlpha(getMultipliedAlpha(color, alpha)); canvas.drawText(texts[i], textX[i], textY[i], paint); } }
Example #23
Source File: CalligraphyTypefaceSpan.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private void apply(final Paint paint) { final Typeface oldTypeface = paint.getTypeface(); final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0; final int fakeStyle = oldStyle & ~typeface.getStyle(); if ((fakeStyle & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fakeStyle & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(typeface); }
Example #24
Source File: LrcView.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
private void initViews(AttributeSet attrs) { TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LrcView); mTextSize = ta.getDimension(R.styleable.LrcView_textSize, 50.0f); mRows = ta.getInteger(R.styleable.LrcView_rows, 5); mDividerHeight = ta.getDimension(R.styleable.LrcView_dividerHeight, 0.0f); int normalTextColor = ta.getColor(R.styleable.LrcView_normalTextColor, 0xffffffff); int currentTextColor = ta.getColor(R.styleable.LrcView_currentTextColor, 0xff00ffde); ta.recycle(); mLrcHeight = (int) (mTextSize + mDividerHeight) * (mRows + 1) + 5; mNormalPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCurrentPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mNormalPaint.setTextSize(mTextSize); Typeface light = LyricsTextFactory.FontCache.get("light", getContext()); mNormalPaint.setTypeface(light); mNormalPaint.setColor(normalTextColor); if (PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("pref_opendyslexic", false)) mNormalPaint.setTypeface(LyricsTextFactory.FontCache.get("dyslexic", getContext())); mCurrentPaint.setTextSize(mTextSize); mCurrentPaint.setTypeface(LyricsTextFactory.FontCache.get("bold", getContext())); mCurrentPaint.setColor(currentTextColor); if (PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("pref_opendyslexic", false)) mCurrentPaint.setTypeface(LyricsTextFactory.FontCache.get("dyslexic", getContext())); }
Example #25
Source File: FontUtil.java From letterpress with Apache License 2.0 | 5 votes |
@NonNull public static SpannableString applyTypeface(@NonNull String text, @NonNull Context context, @NonNull String fontName) { final Typeface typeface = getTypeface(context, fontName); if (typeface == null) { throw new InvalidParameterException("Font '" + fontName + "' not found"); } return applyTypeface(text, typeface); }
Example #26
Source File: GroupSettings.java From XERUNG with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_group_edit); roboto = Typeface.createFromAsset(getAssets(), "font/Roboto-Regular.ttf"); androidface = Typeface.createFromAsset(getAssets(), "font/android.ttf"); initialise(); //setProfile(); }
Example #27
Source File: BaseModeRenderer.java From PercentageChartView with Apache License 2.0 | 5 votes |
public void setTextStyle(int mTextStyle) { if (this.mTextStyle == mTextStyle) return; this.mTextStyle = mTextStyle; mTypeface = (mTypeface == null) ? Typeface.defaultFromStyle(mTextStyle) : Typeface.create(mTypeface, mTextStyle); mTextPaint.setTypeface(mTypeface); updateText(); }
Example #28
Source File: IndexBar.java From ContactsList with Apache License 2.0 | 5 votes |
/****************** * common ******************/ private void initSetting(Context context, AttributeSet attrs) { mOnTouchingLetterChangeListener = getDummyListener(); mNavigators = new ArrayList<>(0); mFocusIndex = -1; TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexBar); float textSize = typedArray.getDimension(R.styleable.IndexBar_letterSize, 8); int letterColor = typedArray.getColor(R.styleable.IndexBar_letterColor, ContextCompat.getColor(getContext(), android.R.color.white)); mLetterSpacingExtra = typedArray.getFloat(R.styleable.IndexBar_letterSpacingExtra, 1.4f); int focusLetterColor = typedArray.getColor(R.styleable.IndexBar_focusLetterColor, ContextCompat.getColor(getContext(), android.R.color.white)); typedArray.recycle(); mPaint = new Paint(); mPaint.setTypeface(Typeface.DEFAULT_BOLD); mPaint.setAntiAlias(true); mPaint.setColor(letterColor); mPaint.setTextSize(textSize); mFocusPaint = new Paint(); mFocusPaint.setTypeface(Typeface.DEFAULT_BOLD); mFocusPaint.setAntiAlias(true); mFocusPaint.setFakeBoldText(true); mFocusPaint.setTextSize(textSize); mFocusPaint.setColor(focusLetterColor); }
Example #29
Source File: RouteAdapter.java From open with GNU General Public License v3.0 | 5 votes |
private SpannableStringBuilder getFullInstructionWithBoldName(String fullInstruction) { final String name = currentInstruction.getName(); final int startOfName = fullInstruction.indexOf(name); final int endOfName = startOfName + name.length(); final StyleSpan boldStyleSpan = new StyleSpan(Typeface.BOLD); final SpannableStringBuilder ssb = new SpannableStringBuilder(fullInstruction); ssb.setSpan(boldStyleSpan, startOfName, endOfName, Spannable.SPAN_INCLUSIVE_INCLUSIVE); return ssb; }
Example #30
Source File: ButtonFlat.java From Social with Apache License 2.0 | 5 votes |
@Override protected void setAttributes(AttributeSet attrs) { // Set text button String text = null; int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1); if(textResource != -1){ text = getResources().getString(textResource); }else{ text = attrs.getAttributeValue(ANDROIDXML,"text"); } if(text != null){ textButton = new TextView(getContext()); textButton.setText(text.toUpperCase()); textButton.setTextColor(backgroundColor); textButton.setTypeface(null, Typeface.BOLD); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); textButton.setLayoutParams(params); addView(textButton); } int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal // Color by hexadecimal background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } }