Code example for Paint

Methods: ascent, descent, measureText

0
    private Rect calcBounds(int index, Paint paint) {
        // Get the title 
        String title = getTitle(index);
        // Calculate the text bounds 
        Rect bounds = new Rect();
        bounds.right = (int) paint.measureText(title);
        bounds.bottom = (int) (paint.descent() - paint.ascent());
        return bounds;
    } 
 
    /** 
     * Returns the title 
     *  
     * @param pos 
     * @return 
     */ 
    private String getTitle(int pos) {
        // Set the default title 
        String title = "title " + pos;
        // If the TitleProvider exist 
        if (titleProvider != null) {