List of usage examples for android.text TextPaint TextPaint
public TextPaint(Paint p)
From source file:com.amitupadhyay.aboutexample.ui.widget.FabOverlapTextView.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FabOverlapTextView); float defaultTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TEXT_SIZE_SP, getResources().getDisplayMetrics()); setFabOverlapGravity(a.getInt(R.styleable.FabOverlapTextView_fabGravity, Gravity.BOTTOM | Gravity.RIGHT)); setFabOverlapHeight(a.getDimensionPixelSize(R.styleable.FabOverlapTextView_fabOverlayHeight, 0)); setFabOverlapWidth(a.getDimensionPixelSize(R.styleable.FabOverlapTextView_fabOverlayWidth, 0)); if (a.hasValue(R.styleable.FabOverlapTextView_android_textAppearance)) { final int textAppearance = a.getResourceId(R.styleable.FabOverlapTextView_android_textAppearance, android.R.style.TextAppearance); TypedArray atp = getContext().obtainStyledAttributes(textAppearance, R.styleable.FontTextAppearance); paint.setColor(atp.getColor(R.styleable.FontTextAppearance_android_textColor, Color.BLACK)); paint.setTextSize(atp.getDimensionPixelSize(R.styleable.FontTextAppearance_android_textSize, (int) defaultTextSize)); if (atp.hasValue(R.styleable.FontTextAppearance_font)) { paint.setTypeface(FontUtil.get(getContext(), atp.getString(R.styleable.FontTextAppearance_font))); }/*from w w w .jav a 2s . c o m*/ atp.recycle(); } if (a.hasValue(R.styleable.FabOverlapTextView_font)) { setFont(a.getString(R.styleable.FabOverlapTextView_font)); } if (a.hasValue(R.styleable.FabOverlapTextView_android_textColor)) { setTextColor(a.getColor(R.styleable.FabOverlapTextView_android_textColor, 0)); } if (a.hasValue(R.styleable.FabOverlapTextView_android_textSize)) { setTextSize(a.getDimensionPixelSize(R.styleable.FabOverlapTextView_android_textSize, (int) defaultTextSize)); } lineHeightHint = a.getDimensionPixelSize(R.styleable.FabOverlapTextView_lineHeightHint, 0); unalignedTopPadding = getPaddingTop(); unalignedBottomPadding = getPaddingBottom(); breakStrategy = a.getInt(R.styleable.FabOverlapTextView_android_breakStrategy, Layout.BREAK_STRATEGY_BALANCED); a.recycle(); }
From source file:org.telegram.ui.Cells.ProfileSearchCell.java
public ProfileSearchCell(Context context) { super(context); if (namePaint == null) { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); nameEncryptedPaint.setColor(0xff00a60e); nameEncryptedPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); onlinePaint.setColor(Theme.MSG_LINK_TEXT_COLOR); offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); offlinePaint.setColor(0xff999999); linePaint = new Paint(); countPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); countPaint.setColor(0xffffffff); countPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); lockDrawable = getResources().getDrawable(R.drawable.list_secret); groupDrawable = getResources().getDrawable(R.drawable.list_group); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); countDrawableGrey = getResources().getDrawable(R.drawable.dialogs_badge2); checkDrawable = getResources().getDrawable(R.drawable.check_list); botDrawable = getResources().getDrawable(R.drawable.bot_list); resetPaint(context);/*from w ww . ja v a2 s . c om*/ } namePaint.setTextSize(AndroidUtilities.dp(17)); nameEncryptedPaint.setTextSize(AndroidUtilities.dp(17)); onlinePaint.setTextSize(AndroidUtilities.dp(16)); offlinePaint.setTextSize(AndroidUtilities.dp(16)); countPaint.setTextSize(AndroidUtilities.dp(13)); avatarImage = new ImageReceiver(this); avatarImage.setRoundRadius(AndroidUtilities.dp(26)); avatarDrawable = new AvatarDrawable(); }
From source file:com.amitupadhyay.aboutexample.ui.widget.CollapsingTitleLayout.java
public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setWillNotDraw(false);//w w w . java 2s .c o m paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout); final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; // first check if all insets set the same titleInsetStart = titleInsetEnd = titleInsetBottom = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInset, 0); titleInsetTop = titleInsetStart; if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetStart)) { final int insetStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetStart, 0); if (isRtl) { titleInsetEnd = insetStart; } else { titleInsetStart = insetStart; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetTop)) { titleInsetTop = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetTop, 0); } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetEnd)) { final int insetEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetEnd, 0); if (isRtl) { titleInsetStart = insetEnd; } else { titleInsetEnd = insetEnd; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetBottom)) { titleInsetBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetBottom, 0); } final int textAppearance = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance, android.R.style.TextAppearance); TypedArray atp = getContext().obtainStyledAttributes(textAppearance, R.styleable.CollapsingTextAppearance); paint.setColor(atp.getColor(R.styleable.CollapsingTextAppearance_android_textColor, Color.WHITE)); collapsedTextSize = atp.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, 0); if (atp.hasValue(R.styleable.CollapsingTextAppearance_font)) { paint.setTypeface(FontUtil.get(getContext(), atp.getString(R.styleable.CollapsingTextAppearance_font))); } atp.recycle(); if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) { collapsedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_collapsedTextSize, 0); paint.setTextSize(collapsedTextSize); } maxExpandedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_maxExpandedTextSize, Integer.MAX_VALUE); lineHeightHint = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_lineHeightHint, 0); maxLines = a.getInteger(R.styleable.CollapsingTitleLayout_android_maxLines, 5); a.recycle(); }
From source file:io.plaidapp.core.ui.widget.CollapsingTitleLayout.java
public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setWillNotDraw(false);//from w w w. j a va2 s . c om paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout); final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; // first check if all insets set the same titleInsetStart = titleInsetEnd = titleInsetBottom = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInset, 0); titleInsetTop = titleInsetStart; if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetStart)) { final int insetStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetStart, 0); if (isRtl) { titleInsetEnd = insetStart; } else { titleInsetStart = insetStart; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetTop)) { titleInsetTop = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetTop, 0); } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetEnd)) { final int insetEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetEnd, 0); if (isRtl) { titleInsetStart = insetEnd; } else { titleInsetEnd = insetEnd; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetBottom)) { titleInsetBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetBottom, 0); } // first check TextAppearance for text attributes if (a.hasValue(R.styleable.CollapsingTitleLayout_android_textAppearance)) { final int textAppearanceId = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance, android.R.style.TextAppearance); TypedArray ta = getContext().obtainStyledAttributes(textAppearanceId, R.styleable.CollapsingTitleLayout); // default collapsedTextSize to regular android:textSize in the TextAppearance collapsedTextSize = ta.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_android_textSize, 0); parseTextAttrs(ta); ta.recycle(); } // then check view for text attributes parseTextAttrs(a); a.recycle(); }
From source file:org.buffer.android.buffertextinputlayout.util.CollapsingTextHelper.java
public CollapsingTextHelper(View view) { mView = view;//from w ww. jav a 2 s. c o m mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:com.funzio.pure2D.ui.vo.FontVO.java
public TextOptions createTextOptions(final UIManager manager) { final TextOptions options = TextOptions.getDefault(); options.id = name;// w ww.ja va 2 s. co m options.inCharacters = manager.evalString(characters); options.inMipmaps = texture_mipmaps; try { options.inTextPaint.setTypeface( Typeface.createFromAsset(manager.getContext().getAssets(), manager.evalString(typeface))); } catch (Exception e) { // Log.e(TAG, "Creating Typeface Error: " + typeface, e); // fallback solution options.inTextPaint.setTypeface(Typeface.create(typeface, TextOptions.getTypefaceStyle(style))); } options.inTextPaint.setTextSize(Float.valueOf(manager.evalString(size)) * mScale); options.inTextPaint.setColor(Color.parseColor(color)); options.inPaddingX = padding_x * mScale; options.inPaddingY = padding_y * mScale; // stroke final float ss = Float.valueOf(manager.evalString(stroke_size)) * mScale; if (ss > 0) { options.inStrokePaint = new TextPaint(options.inTextPaint); options.inStrokePaint.setColor(Color.parseColor(stroke_color)); options.inStrokePaint.setTextSize(ss); } // shadow if (shadow_radius > 0) { if (options.inStrokePaint == null) { options.inStrokePaint = new TextPaint(options.inTextPaint); } options.inStrokePaint.setShadowLayer(shadow_radius * mScale, shadow_dx * mScale, shadow_dy * mScale, Color.parseColor(shadow_color)); } return options; }
From source file:android.support.design.widget.CollapsingTextHelper.java
public CollapsingTextHelper(View view) { mView = view;//from w ww. j a va 2 s . c o m mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:org.telegram.ui.Cells.ContextLinkCell.java
public ContextLinkCell(Context context) { super(context); if (titleTextPaint == null) { titleTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); titleTextPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextPaint.setColor(ContextCompat.getColor(context, R.color.primary_text)); descriptionTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider)); paint.setStrokeWidth(1);//from w w w. ja v a 2 s . c o m DESCRIPTION_TEXT_COLOR = ContextCompat.getColor(context, R.color.secondary_text); } titleTextPaint.setTextSize(AndroidUtilities.dp(15)); descriptionTextPaint.setTextSize(AndroidUtilities.dp(13)); linkImageView = new ImageReceiver(this); letterDrawable = new LetterDrawable(); radialProgress = new RadialProgress(this); TAG = MediaController.getInstance().generateObserverTag(); }
From source file:com.ruesga.rview.widget.MergedStatusChart.java
public MergedStatusChart(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setLayerType(View.LAYER_TYPE_SOFTWARE, null); final Resources res = getResources(); mHeightBarPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, res.getDisplayMetrics()); mMinBarWidth = 0f;//from w w w . ja va 2s .com int openColor = Color.DKGRAY; int mergedColor = Color.DKGRAY; int abandonedColor = Color.DKGRAY; int textColor = Color.WHITE; Resources.Theme theme = context.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.MergedStatusChart, defStyleAttr, 0); int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case R.styleable.MergedStatusChart_heightBarPadding: mHeightBarPadding = a.getDimension(attr, mHeightBarPadding); break; case R.styleable.MergedStatusChart_minBarWidth: mMinBarWidth = a.getDimension(attr, mMinBarWidth); break; case R.styleable.MergedStatusChart_openColor: openColor = a.getColor(attr, openColor); break; case R.styleable.MergedStatusChart_mergedColor: mergedColor = a.getColor(attr, mergedColor); break; case R.styleable.MergedStatusChart_abandonedColor: abandonedColor = a.getColor(attr, abandonedColor); break; case R.styleable.MergedStatusChart_statusLabelTextColor: textColor = a.getColor(attr, textColor); break; } } a.recycle(); mOpenPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mOpenPaint.setStyle(Paint.Style.FILL); mMergedPaint = new Paint(mOpenPaint); mAbandonedPaint = new Paint(mOpenPaint); mOpenPaint.setColor(openColor); mMergedPaint.setColor(mergedColor); mAbandonedPaint.setColor(abandonedColor); mLabelPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelPaint.setTextAlign(Paint.Align.LEFT); mLabelPaint.setFakeBoldText(true); mLabelPaint.setColor(textColor); mLabelPaint .setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 10f, res.getDisplayMetrics())); mLabelPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 2f, res.getDisplayMetrics()); Rect bounds = new Rect(); mLabelPaint.getTextBounds("0", 0, 1, bounds); mLabelHeight = bounds.height(); if (getBackground() == null) { setBackgroundColor(Color.TRANSPARENT); } }
From source file:android.support.design.widget.SubtitleCollapsingTextHelper.java
public SubtitleCollapsingTextHelper(View view) { mView = view;/*from www .j ava 2s. co m*/ mTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }