List of usage examples for android.text TextPaint TextPaint
public TextPaint()
From source file:au.com.zacher.popularmovies.activity.layout.CollapsingTitleLayout.java
public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mTextPaint = new TextPaint(); this.mTextPaint.setAntiAlias(true); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout); this.mExpandedMarginLeft = this.mExpandedMarginRight = this.mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMargin, 0); final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginStart)) { final int marginStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginStart, 0);/*from ww w . j a v a 2s. co m*/ if (isRtl) { this.mExpandedMarginRight = marginStart; } else { this.mExpandedMarginLeft = marginStart; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginEnd)) { final int marginEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginEnd, 0); if (isRtl) { this.mExpandedMarginLeft = marginEnd; } else { this.mExpandedMarginRight = marginEnd; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginBottom)) { this.mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginBottom, 0); } final int tp = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance, android.R.style.TextAppearance); this.setTextAppearance(tp); if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) { this.mCollapsedTitleTextSize = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_collapsedTextSize, 0); } this.mRequestedExpandedTitleTextSize = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_expandedTextSize, this.mCollapsedTitleTextSize); final int interpolatorId = a.getResourceId(R.styleable.CollapsingTitleLayout_textSizeInterpolator, android.R.anim.accelerate_interpolator); this.mTextSizeInterpolator = AnimationUtils.loadInterpolator(context, interpolatorId); a.recycle(); this.mToolbarContentBounds = new Rect(); this.setWillNotDraw(false); }
From source file:com.amitupadhyay.aboutexample.util.CollapsingTextHelper.java
public CollapsingTextHelper(View view) { mView = view;//w w w .j a va 2 s . co m mTextPaint = new TextPaint(); mTextPaint.setAntiAlias(true); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:com.ameron32.apps.tapnotes._trial.ui.CollapsingTitleLayout.java
public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mTextPaint = new TextPaint(); mTextPaint.setAntiAlias(true);/*from w ww.j ava 2 s . co m*/ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout); mExpandedMarginLeft = mExpandedMarginRight = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMargin, 0); final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginStart)) { final int marginStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginStart, 0); if (isRtl) { mExpandedMarginRight = marginStart; } else { mExpandedMarginLeft = marginStart; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginEnd)) { final int marginEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginEnd, 0); if (isRtl) { mExpandedMarginLeft = marginEnd; } else { mExpandedMarginRight = marginEnd; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginBottom)) { mExpandedMarginBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginBottom, 0); } final int tp = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance, android.R.style.TextAppearance); setTextAppearance(tp); if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) { mCollapsedTitleTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_collapsedTextSize, 0); } mRequestedExpandedTitleTextSize = a .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedTextSize, mCollapsedTitleTextSize); final int interpolatorId = a.getResourceId(R.styleable.CollapsingTitleLayout_textSizeInterpolator, android.R.anim.accelerate_interpolator); mTextSizeInterpolator = AnimationUtils.loadInterpolator(context, interpolatorId); a.recycle(); mToolbarContentBounds = new Rect(); setWillNotDraw(false); }
From source file:org.wikipedia.page.shareafact.SnippetImage.java
@NonNull private static Layout drawTextSnippet(@NonNull Canvas canvas, @NonNull CharSequence textSnippet) { final int top = TOP_PADDING; final int maxHeight = 225; final int maxLines = 5; final float maxFontSize = 195.0f; final float minFontSize = 32.0f; TextPaint textPaint = new TextPaint(); textPaint.setAntiAlias(true);//from w ww . j a v a 2s . co m textPaint.setColor(Color.WHITE); textPaint.setTextSize(maxFontSize); textPaint.setStyle(Paint.Style.FILL); textPaint.setTypeface(Typeface.DEFAULT_BOLD); textPaint.setShadowLayer(1.0f, 1.0f, 1.0f, Color.GRAY); StaticLayout textLayout = optimizeTextSize( new TextLayoutParams(textSnippet, textPaint, TEXT_WIDTH, SPACING_MULTIPLIER), maxHeight, maxLines, maxFontSize, minFontSize); canvas.save(); int horizontalCenterOffset = top + (maxHeight - textLayout.getHeight()) / QUARTER; canvas.translate(HORIZONTAL_PADDING, horizontalCenterOffset); textLayout.draw(canvas); canvas.restore(); return textLayout; }
From source file:com.hellofyc.base.util.ViewUtils.java
/** * ?// w ww . j av a2 s . c o m */ public static float getTextWidth(String text, float size) { TextPaint fontPaint = new TextPaint(); fontPaint.setTextSize(size); return fontPaint.measureText(text); }
From source file:com.tr4android.support.extension.widget.CollapsingTextHelper.java
public CollapsingTextHelper(View view) { mView = view;//from w w w . j av a 2 s. c o m mTextPaint = new TextPaint(); mTextPaint.setAntiAlias(true); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:com.ifoer.util.NetPOSPrinter.java
public NetPOSPrinter() { this.result = 0; this.dos = null; this.in = null; this.huanhangSum = 0; this.textPaint = new TextPaint(); this.formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.curDate = new Date(System.currentTimeMillis()); this.str = this.formatter.format(this.curDate); this.company_address = MySharedPreferences.getStringValue(this.mContext, Constants.COMPANYADDRESS); this.company_phone = MySharedPreferences.getStringValue(this.mContext, Constants.COMPANYPHONENUMBER); this.license_plate_number = MySharedPreferences.getStringValue(this.mContext, Constants.LICENSEPLATENUMBERDIAG); this.serialNum = MySharedPreferences.getStringValue(this.mContext, MySharedPreferences.serialNoKey); }
From source file:com.dgmltn.ranger.internal.PinView.java
/** * The view is created empty with a default constructor. Use init to set all the initial * variables for the pin//from w w w . j ava 2 s.c o m * * @param position The position of this point in its parent's view * @param pinRadiusDP the initial size of the pin * @param pinColor the color of the pin * @param textColor the color of the value text in the pin * @param circleRadius the radius of the selector circle * @param circleColor the color of the selector circle */ public void init(PointF position, float pinRadiusDP, int pinColor, int textColor, float circleRadius, int circleColor, float minFont, float maxFont) { mPin = ContextCompat.getDrawable(getContext(), R.drawable.rotate); mPosition = position; mDensity = getResources().getDisplayMetrics().density; mMinPinFont = minFont / mDensity; mMaxPinFont = maxFont / mDensity; mPinPadding = (int) (15f * mDensity); mCircleRadiusPx = circleRadius; mTextYPadding = (int) (3.5f * mDensity); mPinRadiusPx = (int) ((pinRadiusDP == -1 ? DEFAULT_THUMB_RADIUS_DP : pinRadiusDP) * mDensity); // Creates the paint and sets the Paint values mTextPaint = new TextPaint(); mTextPaint.setTypeface(Typeface.MONOSPACE); mTextPaint.setColor(textColor); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(15f * mDensity); // Creates the paint and sets the Paint values mCirclePaint = new Paint(); mCirclePaint.setColor(circleColor); mCirclePaint.setAntiAlias(true); // Color filter for the selection pin mPinFilter = new LightingColorFilter(pinColor, pinColor); // Sets the minimum touchable area, but allows it to expand based on image size mTargetRadiusPx = Math.max(MINIMUM_TARGET_RADIUS_DP * mDensity, mPinRadiusPx); }
From source file:com.grarak.kerneladiutor.elements.SplashView.java
private void draw(Canvas canvas, int x, int y, int radius) { if (radius > 0) canvas.drawCircle(x / 2, y / 2, radius, mPaintCircle); matrix.postRotate(rotate);/*from w w w . j a v a 2 s .c o m*/ Bitmap iconRotate = Bitmap.createBitmap(icon, 0, 0, icon.getWidth(), icon.getHeight(), matrix, false); canvas.drawBitmap(iconRotate, x / 2 - iconRotate.getWidth() / 2, y / 2 - iconRotate.getHeight() / 2, mPaintCircle); TextPaint textPaint = new TextPaint(); textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); textPaint.setColor(textColor); textPaint.setAntiAlias(true); textPaint.setTextAlign(Paint.Align.CENTER); textPaint.setTextSize(textSize); float textHeight = textPaint.descent() - textPaint.ascent(); float textOffset = (textHeight / 2) - textPaint.descent(); canvas.drawText(getResources().getString(R.string.root_waiting), x / 2, y - textOffset - y / 4, textPaint); }
From source file:org.wikipedia.page.shareafact.SnippetImage.java
private static int drawDescription(@NonNull Canvas canvas, @Nullable String description, int top, boolean isArticleRTL) { final int marginBottom = 5; final int maxHeight = 23; final int maxLines = 2; final float maxFontSize = 15.0f; final float minFontSize = 10.0f; if (TextUtils.isEmpty(description)) { return top - marginBottom; }/*from w w w . ja v a 2 s .co m*/ TextPaint textPaint = new TextPaint(); textPaint.setAntiAlias(true); textPaint.setColor(Color.WHITE); textPaint.setTextSize(maxFontSize); textPaint.setStyle(Paint.Style.FILL); textPaint.setShadowLayer(1.0f, 0.0f, 0.0f, Color.GRAY); StaticLayout textLayout = optimizeTextSize( new TextLayoutParams(description, textPaint, DESCRIPTION_WIDTH, SPACING_MULTIPLIER), maxHeight, maxLines, maxFontSize, minFontSize); int left = HORIZONTAL_PADDING; if (isArticleRTL) { left = WIDTH - HORIZONTAL_PADDING - textLayout.getWidth(); } top = top - marginBottom - textLayout.getHeight(); canvas.save(); canvas.translate(left, top); textLayout.draw(canvas); canvas.restore(); return top; }