android Programming Glossary: getpaint
Vertical (rotated) label in Android http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState..
Auto-fit TextView for Android http://stackoverflow.com/questions/16017165/auto-fit-textview-for-android initialize private void initialize mPaint new TextPaint getPaint mMaxTextSize getTextSize mAvailableSpaceRect new RectF mTextCachedSizes..
How to align the text to top of TextView? http://stackoverflow.com/questions/1747196/how-to-align-the-text-to-top-of-textview protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState..
Trying to draw a button: how to set a stroke color and how to “align” a gradient to the bottom without knowing the height? http://stackoverflow.com/questions/2145131/trying-to-draw-a-button-how-to-set-a-stroke-color-and-how-to-align-a-gradient I wanted Set a 1 pixel stroke with a given color. I tried getPaint .setStroke but couldn't figure how to set the stroke color... new RoundRectShape roundedCorner null null normal.getPaint .setShader shader normal.setPadding 7 3 7 5 Create a state list.. WIDTH 3 public RoundRect Shape s super s fillpaint this.getPaint strokepaint new Paint fillpaint strokepaint.setStyle Paint.Style.STROKE..
android ellipsize multiline textview http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview String workingText return new StaticLayout workingText getPaint getWidth getPaddingLeft getPaddingRight Alignment.ALIGN_NORMAL..
Auto Scale TextView Text to Fit within Bounds http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds Get the text view's paint object TextPaint textPaint getPaint Store the current text size float oldTextSize textPaint.getTextSize..
Gettextbounds in android http://stackoverflow.com/questions/5714600/gettextbounds-in-android getText canvas.drawText text 0 text.length mTextX mTextY getPaint Paint pt new Paint pt.setTextSize 10 TextPaint tp getPaint String.. getPaint Paint pt new Paint pt.setTextSize 10 TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize.. currentBounds.bottom 2 Second way i tried TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize..
Marquee Set Speed http://stackoverflow.com/questions/8970927/marquee-set-speed in pixels private int calculateScrollingLen TextPaint tp getPaint Rect rect new Rect String strTxt getText .toString tp.getTextBounds..
Draw text vertically on canvas http://stackoverflow.com/questions/9262494/draw-text-vertically-on-canvas protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState..
Vertical (rotated) label in Android http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate..
Auto-fit TextView for Android http://stackoverflow.com/questions/16017165/auto-fit-textview-for-android AttributeSet attrs int defStyle super context attrs defStyle initialize private void initialize mPaint new TextPaint getPaint mMaxTextSize getTextSize mAvailableSpaceRect new RectF mTextCachedSizes new SparseIntArray if mMaxLines 0 no value was assigned..
How to align the text to top of TextView? http://stackoverflow.com/questions/1747196/how-to-align-the-text-to-top-of-textview is set to the top This is where the magic happens @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save converts 5 pixels into 5dp ..
Trying to draw a button: how to set a stroke color and how to “align” a gradient to the bottom without knowing the height? http://stackoverflow.com/questions/2145131/trying-to-draw-a-button-how-to-set-a-stroke-color-and-how-to-align-a-gradient and works fine and looks nice but I couldn't do two things I wanted Set a 1 pixel stroke with a given color. I tried getPaint .setStroke but couldn't figure how to set the stroke color. How should I do it Align the gradient to the bottom of the button.. new float 5 5 5 5 5 5 5 5 ShapeDrawable normal new ShapeDrawable new RoundRectShape roundedCorner null null normal.getPaint .setShader shader normal.setPadding 7 3 7 5 Create a state list I suppressed settings for pressed . StateListDrawable state_list.. Paint fillpaint strokepaint private static final int WIDTH 3 public RoundRect Shape s super s fillpaint this.getPaint strokepaint new Paint fillpaint strokepaint.setStyle Paint.Style.STROKE strokepaint.setStrokeWidth WIDTH strokepaint.setARGB..
android ellipsize multiline textview http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview ellipsized private Layout createWorkingLayout String workingText return new StaticLayout workingText getPaint getWidth getPaddingLeft getPaddingRight Alignment.ALIGN_NORMAL lineSpacingMultiplier lineAdditionalVerticalPadding false..
Auto Scale TextView Text to Fit within Bounds http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds if text null text.length 0 height 0 width 0 mTextSize 0 return Get the text view's paint object TextPaint textPaint getPaint Store the current text size float oldTextSize textPaint.getTextSize If there is a max text size set use the lesser of that..
Gettextbounds in android http://stackoverflow.com/questions/5714600/gettextbounds-in-android for me to check like this 1 Way i tried CharSequence text getText canvas.drawText text 0 text.length mTextX mTextY getPaint Paint pt new Paint pt.setTextSize 10 TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize.. getText canvas.drawText text 0 text.length mTextX mTextY getPaint Paint pt new Paint pt.setTextSize 10 TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize TypedValue.COMPLEX_UNIT_PX 10 fontPixelSize Home.fltFontRatio.. Ondraw right currentBounds.right Log.e Nrace Ondraw bottom currentBounds.bottom 2 Second way i tried TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize TypedValue.COMPLEX_UNIT_PX 10 fontPixelSize Home.fltFontRatio..
Marquee Set Speed http://stackoverflow.com/questions/8970927/marquee-set-speed length of the text in pixel @return the scrolling length in pixels private int calculateScrollingLen TextPaint tp getPaint Rect rect new Rect String strTxt getText .toString tp.getTextBounds strTxt 0 strTxt.length rect int scrollingLen rect.width..
Draw text vertically on canvas http://stackoverflow.com/questions/9262494/draw-text-vertically-on-canvas getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate..
|