protected void initPaint(Paint paint) { paint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); paint.setTextSize(34); paint.setAntiAlias(true); }
@Override protected synchronized void onPostExecute(Boolean result) { super.onPostExecute(result); if (result) { //Log.i(TAG, "SUCCESS"); if (targetLanguageTextView != null) { targetLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL); } textView.setText(translatedText); textView.setVisibility(View.VISIBLE); textView.setTextColor(activity.getResources().getColor(R.color.translation_text)); // Crudely scale betweeen 22 and 32 -- bigger font for shorter text int scaledSize = Math.max(22, 32 - translatedText.length() / 4); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); } else { Log.e(TAG, "FAILURE"); targetLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC); targetLanguageTextView.setText("Unavailable"); } // Turn off the indeterminate progress indicator if (progressView != null) { progressView.setVisibility(View.GONE); } } }
try { setTextSize(TypedValue.COMPLEX_UNIT_PX, a.getDimensionPixelSize(0, 0)); setTypeface(Typeface.defaultFromStyle(a.getInt(1, Typeface.BOLD))); setText(a.getString(2)); } finally {
translationLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL); translationLanguageTextView.setVisibility(View.VISIBLE);
/** * Sets a text style for the layout. * * @param style The text style for the layout * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setTextStyle(int style) { return setTypeface(Typeface.defaultFromStyle(style)); }
@Override public void draw(Canvas canvas) { int size = (int) -ascent; // Draw the circle paint.setStyle(Paint.Style.FILL); paint.setColor(Color.YELLOW); canvas.drawCircle(size/2, size/2, size/2 , paint); // Draw the ring paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.RED); float ringWidth = size / 10; paint.setStrokeWidth(ringWidth); canvas.drawCircle(size/2, size/2, size/2 - ringWidth/2, paint); // Draw the text float ratio = 0.4f; paint.setStyle(Paint.Style.FILL); paint.setColor(Color.BLACK); paint.setTextAlign(Paint.Align.CENTER); paint.setTextSize(textSize * ratio); paint.setStrokeWidth(strokeWidth); paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); int x = size / 2; int y = (int) (size/2 - ((descent + ascent)/2) * ratio); canvas.drawText(number, x, y, paint); }
builder.setTypeface(Typeface.defaultFromStyle(textStyle));
public static void applyFontStyle(Paint paint, int style, int weight, String family) { int oldStyle; Typeface typeface = paint.getTypeface(); if (typeface == null) { oldStyle = 0; } else { oldStyle = typeface.getStyle(); } int want = 0; if ((weight == Typeface.BOLD) || ((oldStyle & Typeface.BOLD) != 0 && weight == WXStyle.UNSET)) { want |= Typeface.BOLD; } if ((style == Typeface.ITALIC) || ((oldStyle & Typeface.ITALIC) != 0 && style == WXStyle.UNSET)) { want |= Typeface.ITALIC; } if (family != null) { typeface = getOrCreateTypeface(family, want); } if (typeface != null) { paint.setTypeface(Typeface.create(typeface, want)); } else { paint.setTypeface(Typeface.defaultFromStyle(want)); } }
typeface = Typeface.defaultFromStyle(style); textPaint.setTypeface(Typeface.defaultFromStyle(style));
builder.setTypeface(Typeface.defaultFromStyle(textStyle)); } else { builder.setTypeface(null);
@Override public void setString(T view, String value) { int typeface = ParseHelper.parseTextStyle(value); view.setTypeface(Typeface.defaultFromStyle(typeface)); } });
private Path getPath() { Path textPath = new Path(); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.RED); paint.setTextSize(120); paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD_ITALIC)); String s = mEditText.getText().toString().length() <= 0 ? "cece" : mEditText.getText().toString(); paint.getTextPath(s, 0, s.length(), 0, 200, textPath); textPath.close(); return textPath; } }
private TextView addLabel(LinearLayout certificateView, String label) { TextView t = new TextView(mContext); ApiCompatibilityUtils.setTextAlignment(t, View.TEXT_ALIGNMENT_VIEW_START); t.setPadding(mPadding, mPadding / 2, mPadding, 0); t.setText(label); t.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.connection_info_popup_text)); certificateView.addView(t); return t; }
private void settingTitle() { if (StringUtil.isEmpty(mTitle)) { mTvTitle.setVisibility(INVISIBLE); } else { mTvTitle.setVisibility(VISIBLE); mTvTitle.setText(mTitle); mTvTitle.setTypeface(Typeface.defaultFromStyle(mTitleStyle)); mTvTitle.setTextSize(TransitionTools.px2sp(mContext, mTitleSize)); mTvTitle.setTextColor(mTitleColor); } }
private void settingRightText() { if (StringUtil.isEmpty(mRightText)) { mTvRight.setVisibility(GONE); } else { mTvRight.setVisibility(VISIBLE); mIvRight.setVisibility(GONE); mTvRight.setText(mRightText); mTvRight.setTextSize(TransitionTools.px2sp(mContext, mRightTextSize)); mTvRight.setTextColor(mRightTextColor); mTvRight.setPadding(mRightTextPaddingStart, 0, mRightTextPaddingEnd, 0); mTvRight.setTypeface(Typeface.defaultFromStyle(mRightTextStyle)); } }
public BottomSheetDialog(Context context) { this.mContext = context; WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); display = windowManager.getDefaultDisplay(); defaultBottomBtnStyle = new SheetItemTextStyle(); defaultBottomBtnStyle.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); }
assertEquals(Typeface.BOLD_ITALIC, textPaint.getTypeface().getStyle()); PromptUtils.setTypeface(textPaint, Typeface.defaultFromStyle(Typeface.BOLD), Typeface.BOLD_ITALIC); assertEquals(Typeface.BOLD_ITALIC, textPaint.getTypeface().getStyle()); PromptUtils.setTypeface(textPaint, Typeface.defaultFromStyle(Typeface.BOLD), Typeface.ITALIC); assertEquals(Typeface.ITALIC, textPaint.getTypeface().getStyle()); PromptUtils.setTypeface(textPaint, Typeface.defaultFromStyle(Typeface.BOLD), Typeface.BOLD); assertEquals(Typeface.BOLD, textPaint.getTypeface().getStyle()); PromptUtils.setTypeface(textPaint, Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC); assertEquals(Typeface.ITALIC, textPaint.getTypeface().getStyle()); PromptUtils.setTypeface(textPaint, Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.BOLD); assertEquals(Typeface.BOLD, textPaint.getTypeface().getStyle());
public static StringTexture newInstance( String text, float textSize, int color, float lengthLimit, boolean isBold) { TextPaint paint = getDefaultPaint(textSize, color); if (isBold) { paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); } text = TextUtils.ellipsize( text, paint, lengthLimit, TextUtils.TruncateAt.END).toString(); return newInstance(text, paint); }
@Test public void testGetTypeface() throws Exception { TextAttributes attributes = new TextAttributes(); Typeface typeface = Typeface.defaultFromStyle(Typeface.NORMAL); attributes.typeface = typeface; assertEquals(typeface, attributes.getTypeface()); }
@Test public void testSetTypeface() throws Exception { TextAttributes attributes = new TextAttributes(); Typeface typeface = Typeface.defaultFromStyle(Typeface.NORMAL); attributes.setTypeface(typeface); assertEquals(typeface, attributes.typeface); }