Code example for StaticLayout

Methods: draw, getWidth

0
 
    public void render(Canvas c, float x, float y) {
        if (layout != null){
            c.save();
            // the position in question is the center of the text 
            c.translate(x + layout.getWidth() / 2.0f, y);
            layout.draw(c);
 
            c.restore();
        } 
    } 
 
    public int getHeight(){ 
        if (layout != null){
            return layout.getHeight();
        } 
        return 0; 
    } 
 
}