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!
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
editText.setTypeface(Typeface.SERIF); as like as TextView.
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
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);
Related
I am developing android application in Marathi language,
for that i want to set Marathi font to text view.
So please let me know how to set that
Thanking you..
Put your font in assets folder, then create new Typeface from it
Here is an example
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "SomeFont.ttf");
txt.setTypeface(font);
First of all put your fonts in assests folder in your project.
then in textview in java file where you want to put marathi, use this code:
Typeface mfont = Typeface.createFromAsset(getAssets(), "roboto_light.otf");
<your Textview>.setTypeface(mfont);
Download marathi fonts and save it in assests folder and set typeface using that font.
Sample:
TextView textView = (TextView)findViewById(R.id.textview);
Typeface tf = Typeface.createFromAsset(getAssests(), "name_of_font.ttf");
textView.setTypeface(tf);
you need to pass unicode character like\u... to you textview text.
you can use converter to convert the language. Or can take a look http://www.unicodeonline.com/
For getting the exact value you can pass your unicode into
ResourceBundle.getBundle(unicodestoragelocation,locale).getString(UnicodeValue)
I am trying to change typeface in a Textview which shows a chinese text.
My code is:
chinesetext = (TextView)findViewById(R.id.textChinese);
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/DFXSM1B.ttf");
chinesetext.setTypeface(tf);
DFXSM1B.ttf is in my assets/fonts folder.
I am unable to see the textview typeface changed.
How can I change to a custom typeface in a chinese text ?
I am using paint to set typeface, it dosen't work for chinese text...
I used the font family is 思源宋体 Medium
and my code like this: (that is very simple)
var typeface = Typeface.createFromAsset(context.assets, "fonts/font1.otf")
paint.typeface = typeface
All the files in asset folder must have lower-cased names.
Rename the file in lower case (dfxsm1b.ttf) and it must work.
I am developing application which is having Gujarati font in text-view but my problem is that in text-view it shows the box instead of Gujarati font i have tried by "TypeFace" and text is at string.xml but it is not working please help me i have to submit on tuesday at school so please please help me
Thank you in advance
TextView cap = (TextView) view.findViewById(R.id.caption);
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/gujaratifont.ttf");
cap.setTypeface(tf);
cap.setText(R.string.gujarati);
Drop your file in assets Folder.
Try to do like this. getResources().getString(R.string.gujarati);
Its one reason is because Resources could not get to the TextView. Just Check it out.
TextView cap = (TextView) view.findViewById(R.id.caption);
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),"fonts/gujaratifont.ttf");
//(or)
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),"gujaratifont.ttf");
cap.setTypeface(tf);
cap.setText(R.string.gujarati);
and place your font file in assets folder.
i.e., create a folder with name fonts in assets folder and place that gujarati font in fonts folder.
if you want gujarati font download it from HERE
TextView mtxt = (TextView) findViewById(R.id.action_settings);
Typeface face1 = Typeface.createFromAsset(getAssets(),
"Lohit-Gujarati.ttf");
mtxt.setTypeface(face1);
mtxt.setText("પૂર્વ વડાપ્રધાન રાજીવ ગાંધી");
I am creating an app which uses math fonts like lambda,integral etc in android. And how could i use an keyboard for that? plz help nothing found on google
If you have a .ttf font file with your symbols, place it in the /assets folder then use it on a TextView like this:
Typeface font = Typeface.createFromAsset(getAssets(), "font.ttf");
TextView tv = (TextView) findViewById(R.id...);
tv.setTypeface(font);
As for using the keyboard see:
http://www.addictivetips.com/mobile/create-your-own-custom-keyboard-for-android-devices/ and creating custom android keyboard layout
I want to change the font face and styles in android. How to do this? Am using emulator. Is this possible to change in emulator. Is there any permissions available to do that. Thanks in Advance.
in android only five fonttype-face
TypeFace
Typeface.DEFAULT
Typeface.MONOSPACE
Typeface.SANS_SERIF
Typeface.DEFAULT_BOLD
Typeface.SERIF
and font-type
Typeface.NORMAL
Typeface.BOLD
Typeface.BOLD_ITALIC
Typeface.ITALIC
you can use like as
textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
and other way is you can download any .ttf file and put it in asset folder and use like as this
Typeface type=Typeface.createFromAsset(context.getAssets(),
"DroidSansMono.ttf");
textView.setTypeface(type, null);
You can change the font style and font face in your XML files. For example if you want to change your Button's style and face. Choose your button in xml and follow the below methods :
Button -> Right Click -> Properties -> Typeface and style
Hope this will help you.
If you want to change in code ;
This is good reference;
http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/
what you want?. Do you want to change the font face and styles of text in textview. if yes then use this
Typeface type = Typeface.createFromAsset(this.getAssets(),"your font name");
text.setTypeface(type);
and for styles use these links:
Style-resource
Themes
If you want to use a font which is not default (like "Helvetica") for the text in Android application then put the font file(Helvetic.ttf) in assets folder and do use this code as below:
Typeface tf= Typeface.createFromAsset(getAssets(), "Helvetica.ttf");
TextView mTextView =(TextView) findViewById(R.id.text);
mTextView.setTypeface(tf);
if u want to use custom font jus download .ttf file and put the file into assets folder
and use like this:
TextView tv=(TextView)findViewById(R.id.textView);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/arial.ttf");
tv.setTypeface(tf);