Code example for TextPaint

Methods: getTypeface, setColor, setTextSize, setTypeface

0
         
        /** 
         * @see android.text.style.CharacterStyle#updateDrawState(android.text.TextPaint) 
         */ 
        @Override public void updateDrawState(TextPaint paint){
            if(paint.getTypeface()==null){
                paint.setTypeface(Typeface.create((Typeface)null,Typeface.NORMAL));
            } 
             
            if(this._attributes.hasAttribute("bold")){
                if(this._attributes.getAttributeAsBoolean("bold")){     
                    paint.setTypeface(Typeface.create(paint.getTypeface(),paint.getTypeface().getStyle()|Typeface.BOLD));
                }else{ 
                    paint.setTypeface(Typeface.create(paint.getTypeface(),paint.getTypeface().getStyle()^Typeface.BOLD));
                } 
            } 
             
            if(this._attributes.hasAttribute("italic")){
                if(this._attributes.getAttributeAsBoolean("italic")){
                    paint.setTypeface(Typeface.create(paint.getTypeface(),paint.getTypeface().getStyle()|Typeface.ITALIC));
                }else{ 
                    paint.setTypeface(Typeface.create(paint.getTypeface(),paint.getTypeface().getStyle()^Typeface.ITALIC));  //If the attribute is false, we don't want italics.  Just XOR it out.   
                } 
            } 
             
            if(this._attributes.hasAttribute("font_color")){
                paint.setColor(this._attributes.getAttributeAsColor("font_color"));
            } 
             
            if(this._attributes.hasAttribute("font_size")){
                paint.setTextSize(this._attributes.getAttributeAsInteger("font_size"));
            } 
        }         
    } 
     
    /**