get String Width via TextPaint - Android Graphics

Android examples for Graphics:Paint

Description

get String Width via TextPaint

Demo Code


//package com.java2s;

import android.text.TextPaint;

public class Main {

    public static float getStringWidth(String str, TextPaint paint) {
        float strWidth = paint.measureText(str);
        return strWidth;
    }/*from   w  ww .  ja va  2s.  c  o  m*/
}

Related Tutorials