0

I am new to android development, I need to implement Rich text Editor in my Application. So i googled and found some solutions. I am using this solution:

http://code.google.com/p/android-richtexteditor/source/browse/?r=4#svn/trunk/src/net/sgoliver

It supports the Bold, Italic and Underline in it. Now I want to change the font-style of selected text in EditText, How do i do that?

I know how to set the font-style for all the text in EditText. Suggestions will be appriciated!

Community
  • 1
  • 1

4 Answers4

2

Copy the font files (*.ttf) to the assets folder of your application.

Consider I have copied the font file "verdana.TTF" to the assets folder, then the following code will set the font to verdana

EditText et=(EditText) findViewById(R.id.editText1);
Typeface tf =   Typeface.createFromAsset(getAssets(),"verdana.TTF");
et.setTypeface(tf);

Hope you got the solution

Anu
  • 1,884
  • 14
  • 30
0
editText.setTypeface(Typeface.SERIF); as like as TextView.
swiftBoy
  • 35,607
  • 26
  • 136
  • 135
0
Typeface tf =   Typeface.createFromAsset(getAssets(),"fonts/Comic.ttf");
EditText et =   (EditText)findViewById(R.id.et);
et.setTypeface(tf);

you can place ttf file in assets and set font style here

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
0

try this code..create font folder like this assets/font and put your font file in it..

 edittxt = (EditText) findViewById(R.id.edittxt);

 Typeface myTypeface = Typeface.createFromAsset( this.getAssets(), "font/YOURFONT.otf");

 edittxt.setTypeface(myTypeface);    
Ketan Ahir
  • 6,678
  • 1
  • 23
  • 45