¡@

Home 

2014/10/16 ¤W¤È 08:26:02

android Programming Glossary: textpaint

Vertical (rotated) label in Android

http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android

@Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState.. void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState.. textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate..

How do you draw text with a border on a MapView in Android?

http://stackoverflow.com/questions/1723846/how-do-you-draw-text-with-a-border-on-a-mapview-in-android

draw Canvas canvas MapView mapView boolean shadow Paint textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setTextAlign.. MapView mapView boolean shadow Paint textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setTextAlign Paint.Align.CENTER.. textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setTextAlign Paint.Align.CENTER textPaint.setTextSize 16 textPaint.setTypeface..

How to get string width on Android?

http://stackoverflow.com/questions/3630086/how-to-get-string-width-on-android

you Can do the following Rect bounds new Rect Paint textPaint textView.getPaint textPaint.getTextBounds text 0 text.length.. Rect bounds new Rect Paint textPaint textView.getPaint textPaint.getTextBounds text 0 text.length bounds int height bounds.height..

How to display popup on tapping overlay in android?

http://stackoverflow.com/questions/4486864/how-to-display-popup-on-tapping-overlay-in-android

double toLat toLng private Paint innerPaint borderPaint textPaint private boolean isRemovePriorPopup false private boolean temp.. 2 return borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255.. borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias..

How to layout a 'grid' of images in the center of the screen

http://stackoverflow.com/questions/4592065/how-to-layout-a-grid-of-images-in-the-center-of-the-screen

Auto Scale TextView Text to Fit within Bounds

http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds

0 return Get the text view's paint object TextPaint textPaint getPaint Store the current text size float oldTextSize textPaint.getTextSize.. getPaint Store the current text size float oldTextSize textPaint.getTextSize If there is a max text size set use the lesser of.. the required text height int textHeight getTextHeight text textPaint width targetTextSize Until we either fit within our text view..

Custom tap window on Google Map

http://stackoverflow.com/questions/6385908/custom-tap-window-on-google-map

mapLocationViewer private Paint innerPaint borderPaint textPaint private Point arrowPointCoordinates new Point The currently.. 2 return borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias.. borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias..

Draw text vertically on canvas

http://stackoverflow.com/questions/9262494/draw-text-vertically-on-canvas

@Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState.. void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState.. textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate..

Multiple TypeFace in single TextView

http://stackoverflow.com/questions/10675070/multiple-typeface-in-single-textview

import android.graphics.Typeface import android.text.TextPaint import android.text.style.TypefaceSpan public class CustomTypefaceSpan.. family newType type @Override public void updateDrawState TextPaint ds applyCustomTypeFace ds newType @Override public void updateMeasureState.. ds newType @Override public void updateMeasureState TextPaint paint applyCustomTypeFace paint newType private static void..

Vertical (rotated) label in Android

http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android

@Override 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

import android.text.StaticLayout import android.text.TextPaint import android.util.AttributeSet import android.util.SparseIntArray.. private SparseIntArray mTextCachedSizes private TextPaint mPaint private float mMaxTextSize private float mSpacingMult.. defStyle initialize private void initialize mPaint new TextPaint getPaint mMaxTextSize getTextSize mAvailableSpaceRect new RectF..

How to align the text to top of TextView?

http://stackoverflow.com/questions/1747196/how-to-align-the-text-to-top-of-textview

happens @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState..

Remove underline from links in TextView - Android

http://stackoverflow.com/questions/4096851/remove-underline-from-links-in-textview-android

a customized version of URLSpan which doesn't enable the TextPaint's underline property private class URLSpanNoUnderline extends.. url super url @Override public void updateDrawState TextPaint ds super.updateDrawState ds ds.setUnderlineText false share..

How can I use TypefaceSpan or StyleSpan with a custom Typeface?

http://stackoverflow.com/questions/4819049/how-can-i-use-typefacespan-or-stylespan-with-a-custom-typeface

import android.graphics.Typeface import android.text.TextPaint import android.text.style.TypefaceSpan public class CustomTypefaceSpan.. family newType type @Override public void updateDrawState TextPaint ds applyCustomTypeFace ds newType @Override public void updateMeasureState.. ds newType @Override public void updateMeasureState TextPaint paint applyCustomTypeFace paint newType private static void..

Auto Scale TextView Text to Fit within Bounds

http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds

import android.text.StaticLayout import android.text.TextPaint import android.util.AttributeSet import android.util.TypedValue.. 0 mTextSize 0 return Get the text view's paint object TextPaint textPaint getPaint Store the current text size float oldTextSize.. measuring private int getTextHeight CharSequence source TextPaint paint int width float textSize Update the text paint object..

Gettextbounds in android

http://stackoverflow.com/questions/5714600/gettextbounds-in-android

mTextY getPaint Paint pt new Paint pt.setTextSize 10 TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize.. Ondraw bottom currentBounds.bottom 2 Second way i tried TextPaint tp getPaint String string haa Rect currentBounds new Rect this.setTextSize..

Android Linkify text - Spannable Text in Single Text View - As like Twitter tweet

http://stackoverflow.com/questions/7570239/android-linkify-text-spannable-text-in-single-text-view-as-like-twitter-twee

Url this.Url Url @Override public void updateDrawState TextPaint ds Customize your Text Look if required ds.setColor Color.YELLOW..

ListView: TextView with LinkMovementMethod makes list item unclickable?

http://stackoverflow.com/questions/8558732/listview-textview-with-linkmovementmethod-makes-list-item-unclickable

widget @Override public void updateDrawState TextPaint ds super.updateDrawState ds ds.setUnderlineText false In the..

select a word on a tap in TextView/EditText

http://stackoverflow.com/questions/8612652/select-a-word-on-a-tap-in-textview-edittext

Toast.LENGTH_SHORT .show public void updateDrawState TextPaint ds super.updateDrawState ds OLD ANSWER I wanted to handle.. .toString Log.d tapped on s public void updateDrawState TextPaint ds super.updateDrawState ds public static Integer getIndices..

Marquee Set Speed

http://stackoverflow.com/questions/8970927/marquee-set-speed

length in pixels private int calculateScrollingLen TextPaint tp getPaint Rect rect new Rect String strTxt getText .toString..

Draw text vertically on canvas

http://stackoverflow.com/questions/9262494/draw-text-vertically-on-canvas

import android.graphics.Canvas import android.text.TextPaint import android.util.AttributeSet import android.view.Gravity.. @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState..

Android: textview hyperlink

http://stackoverflow.com/questions/9852184/android-textview-hyperlink

String url super url @Override public void updateDrawState TextPaint ds super.updateDrawState ds ds.setUnderlineText false Then..

Vertical (rotated) label in Android

http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android

setMeasuredDimension getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate.. getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate getWidth 0.. @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate getWidth 0 canvas.rotate 90 else canvas.translate..

How do you draw text with a border on a MapView in Android?

http://stackoverflow.com/questions/1723846/how-do-you-draw-text-with-a-border-on-a-mapview-in-android

example code found in one of my overlays @Override public void draw Canvas canvas MapView mapView boolean shadow Paint textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setTextAlign Paint.Align.CENTER textPaint.setTextSize 16 textPaint.setTypeface.. one of my overlays @Override public void draw Canvas canvas MapView mapView boolean shadow Paint textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setTextAlign Paint.Align.CENTER textPaint.setTextSize 16 textPaint.setTypeface Typeface.DEFAULT_BOLD.. void draw Canvas canvas MapView mapView boolean shadow Paint textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setTextAlign Paint.Align.CENTER textPaint.setTextSize 16 textPaint.setTypeface Typeface.DEFAULT_BOLD canvas.drawText Some..

How to get string width on Android?

http://stackoverflow.com/questions/3630086/how-to-get-string-width-on-android

one yourself with your desired text appearance. Using a Textview you Can do the following Rect bounds new Rect Paint textPaint textView.getPaint textPaint.getTextBounds text 0 text.length bounds int height bounds.height int width bounds.width share..

How to display popup on tapping overlay in android?

http://stackoverflow.com/questions/4486864/how-to-display-popup-on-tapping-overlay-in-android

shadowIcon private MapLocationViewer mapLocationViewer double toLat toLng private Paint innerPaint borderPaint textPaint private boolean isRemovePriorPopup false private boolean temp true first true firstDraw true public boolean tempDefaule.. true borderPaint.setStyle Style.STROKE borderPaint.setStrokeWidth 2 return borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias true return textPaint In this code.. Style.STROKE borderPaint.setStrokeWidth 2 return borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias true return textPaint In this code i have design a..

How to layout a 'grid' of images in the center of the screen

http://stackoverflow.com/questions/4592065/how-to-layout-a-grid-of-images-in-the-center-of-the-screen

Auto Scale TextView Text to Fit within Bounds

http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds

is no text 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.. 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 and the default text size float targetTextSize mMaxTextSize.. 0 Math.min mTextSize mMaxTextSize mTextSize Get the required text height int textHeight getTextHeight text textPaint width targetTextSize Until we either fit within our text view or we had reached our min text size incrementally try smaller..

Custom tap window on Google Map

http://stackoverflow.com/questions/6385908/custom-tap-window-on-google-map

Handler private boolean flag false private MapLocationViewer mapLocationViewer private Paint innerPaint borderPaint textPaint private Point arrowPointCoordinates new Point The currently selected Map Location...if any is selected. This tracks whether.. true borderPaint.setStyle Style.STROKE borderPaint.setStrokeWidth 2 return borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias true return textPaint package com.pocketjourney.view.. Style.STROKE borderPaint.setStrokeWidth 2 return borderPaint public Paint getTextPaint if textPaint null textPaint new Paint textPaint.setARGB 255 255 255 255 textPaint.setAntiAlias true return textPaint package com.pocketjourney.view..

Draw text vertically on canvas

http://stackoverflow.com/questions/9262494/draw-text-vertically-on-canvas

setMeasuredDimension getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate.. getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate getWidth.. @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown canvas.translate getWidth 0 canvas.rotate 90 else canvas.translate..

Multiple TypeFace in single TextView

http://stackoverflow.com/questions/10675070/multiple-typeface-in-single-textview

Class package my.app import android.graphics.Paint import android.graphics.Typeface import android.text.TextPaint import android.text.style.TypefaceSpan public class CustomTypefaceSpan extends TypefaceSpan private final Typeface newType.. public CustomTypefaceSpan String family Typeface type super family newType type @Override public void updateDrawState TextPaint ds applyCustomTypeFace ds newType @Override public void updateMeasureState TextPaint paint applyCustomTypeFace paint newType.. public void updateDrawState TextPaint ds applyCustomTypeFace ds newType @Override public void updateMeasureState TextPaint paint applyCustomTypeFace paint newType private static void applyCustomTypeFace Paint paint Typeface tf int oldStyle Typeface..

Vertical (rotated) label in Android

http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android

widthMeasureSpec setMeasuredDimension getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown..

Auto-fit TextView for Android

http://stackoverflow.com/questions/16017165/auto-fit-textview-for-android

import android.os.Build import android.text.Layout.Alignment import android.text.StaticLayout import android.text.TextPaint import android.util.AttributeSet import android.util.SparseIntArray import android.util.TypedValue import android.widget.TextView.. private RectF mTextRect new RectF private RectF mAvailableSpaceRect private SparseIntArray mTextCachedSizes private TextPaint mPaint private float mMaxTextSize private float mSpacingMult 1.0f private float mSpacingAdd 0.0f private float mMinTextSize.. context 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..

How to align the text to top of TextView?

http://stackoverflow.com/questions/1747196/how-to-align-the-text-to-top-of-textview

sure that the gravity 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..

Remove underline from links in TextView - Android

http://stackoverflow.com/questions/4096851/remove-underline-from-links-in-textview-android

s.setSpan span start end 0 textView.setText s This requires a customized version of URLSpan which doesn't enable the TextPaint's underline property private class URLSpanNoUnderline extends URLSpan public URLSpanNoUnderline String url super url @Override..

How can I use TypefaceSpan or StyleSpan with a custom Typeface?

http://stackoverflow.com/questions/4819049/how-can-i-use-typefacespan-or-stylespan-with-a-custom-typeface

did package de.myproject.text.style import android.graphics.Paint import android.graphics.Typeface import android.text.TextPaint import android.text.style.TypefaceSpan public class CustomTypefaceSpan extends TypefaceSpan private final Typeface newType.. CustomTypefaceSpan String family Typeface type super family newType type @Override public void updateDrawState TextPaint ds applyCustomTypeFace ds newType @Override public void updateMeasureState TextPaint paint applyCustomTypeFace paint.. public void updateDrawState TextPaint ds applyCustomTypeFace ds newType @Override public void updateMeasureState TextPaint paint applyCustomTypeFace paint newType private static void applyCustomTypeFace Paint paint Typeface tf int oldStyle..

Auto Scale TextView Text to Fit within Bounds

http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds

android.content.Context import android.text.Layout.Alignment import android.text.StaticLayout import android.text.TextPaint import android.util.AttributeSet import android.util.TypedValue import android.widget.TextView Text view that auto adjusts.. or there is no text 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.. and use a static layout to render text off screen before measuring private int getTextHeight CharSequence source TextPaint paint int width float textSize Update the text paint object paint.setTextSize textSize Measure using a static layout StaticLayout..

Gettextbounds in android

http://stackoverflow.com/questions/5714600/gettextbounds-in-android

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 TypedValue.COMPLEX_UNIT_PX 10 fontPixelSize Home.fltFontRatio.. Log.e 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..

Android Linkify text - Spannable Text in Single Text View - As like Twitter tweet

http://stackoverflow.com/questions/7570239/android-linkify-text-spannable-text-in-single-text-view-as-like-twitter-twee

ClickableSpan String Url public MyCustomSpannable String Url this.Url Url @Override public void updateDrawState TextPaint ds Customize your Text Look if required ds.setColor Color.YELLOW ds.setFakeBoldText true ds.setStrikeThruText true ds.setTypeface..

ListView: TextView with LinkMovementMethod makes list item unclickable?

http://stackoverflow.com/questions/8558732/listview-textview-with-linkmovementmethod-makes-list-item-unclickable

listener @Override public void onClick View widget mListener.onClick widget @Override public void updateDrawState TextPaint ds super.updateDrawState ds ds.setUnderlineText false In the activity I have in onCreate ... listView.setOnItemClickListener..

select a word on a tap in TextView/EditText

http://stackoverflow.com/questions/8612652/select-a-word-on-a-tap-in-textview-edittext

Log.d tapped on mWord Toast.makeText widget.getContext mWord Toast.LENGTH_SHORT .show public void updateDrawState TextPaint ds super.updateDrawState ds OLD ANSWER I wanted to handle click in my own Activity. I solved it by following code private.. .subSequence tv.getSelectionStart tv.getSelectionEnd .toString Log.d tapped on s public void updateDrawState TextPaint ds super.updateDrawState ds public static Integer getIndices String s char c int pos s.indexOf c 0 List Integer indices..

Marquee Set Speed

http://stackoverflow.com/questions/8970927/marquee-set-speed

the scrolling 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..

Draw text vertically on canvas

http://stackoverflow.com/questions/9262494/draw-text-vertically-on-canvas

please post a link in the comments. import android.content.Context import android.graphics.Canvas import android.text.TextPaint import android.util.AttributeSet import android.view.Gravity import android.widget.TextView public class VerticalTextView.. setMeasuredDimension getMeasuredHeight getMeasuredWidth @Override protected void onDraw Canvas canvas TextPaint textPaint getPaint textPaint.setColor getCurrentTextColor textPaint.drawableState getDrawableState canvas.save if topDown..

Android: textview hyperlink

http://stackoverflow.com/questions/9852184/android-textview-hyperlink

extends URLSpan public URLSpanNoUnderline String url super url @Override public void updateDrawState TextPaint ds super.updateDrawState ds ds.setUnderlineText false Then add this method in your main Activity class where you have the..