2011-09-07 5 views

Odpowiedz

8
Paint p = new Paint(); 
p.setTypeface(TypeFace obj); // if custom font use `TypeFace.createFromFile` 
p.setTextSize(float size); 
float textWidth = p.measureText("Your string"); 
// you get the width here and textsize is the height. 
2

Klasa Farba ma measureText() metoda, która daje szerokość w obrocie

Paint p = new Paint(); 
int INFO_WINDOW_WIDTH = (int)p.measureText("this is string"); 

a inny jest Paint.getTextBounds

8
Paint mPaint = new Paint(); 
mPaint.setTextSize(/*put here ur size*/); 
mPaint.setTypeface(/* put here ur font type */); 
Rect bounds = new Rect(); 
mPaint.getTextBounds(text, 0, text.length(), bounds); 

następnie nawiązać połączenie z

bounds.width(); 

bounds.height(); 
Powiązane problemy