Saturday 22 December 2012

Customize handwriting fonts Android [ Android tutorial ] ^^


Today we will see a little Android tutorial very simple but can be terribly useful when developing your applications Android . We will see how to customize handwriting fonts in Android .

XML

As always, create a new project Android , then follow the file main.xml where you will insert the following code (there is nothing special about this code so I'll move quickly):
the famous typeface Comic Sans MS. " 
            android: textSize = "18px" 
            /> 
 
</ LinearLayout >
----------------------

JAVA code

Before looking at the Java code, it is time to put the TTF file (for me I chose the font Comic Sans MS) in the folder assets of your Android project . Once this is done, we can move on to a few lines of Java code needed to change the font of your Android applications . Simply insert a few lines in the methodonCreate your main Activity:
TextView texteView =  ( TextView ) findViewById ( R. id . custom_font ) ; 
make Typeface = Typeface. createFromAsset ( getAssets ( ) , "comic.ttf" ) ; 
texteView. setTypeface ( are ) ;
Your TextView should be displayed with the font you have chosen:
This trick I found on the site mobile tuts + (in English) you will find more tips on writing text into yourAndroid applications (color, size, typeface, etc ...). So much for today is finished, yes I know it was short, but I hope this helps in your future apps!


No comments:

Post a Comment

Free Automatic Backlink