How to use mathematical fonts in android? - android

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

Related

Adding costum font to android in font family xml

In the android guides for Fonts in XML, they give the example of font family XML you create by adding:
android:font="#font/lobster_regular"
Which I think its the font you added to your assets/font folder. But when i try it I don't get it why it isn't able to find the font I've added. It only fins sans, serif and mono-space. Anyone have a clue what it might be the problem?
I know there are other ways to add a custom font, but due to the material calendar that I want to use, I need it to define in the styles XML, only way to customize it. I tried calligraphy lib, but does not help.
Using typeface you easily set font family
Typeface type = Typeface.createFromAsset(getAssets(),
"fonts/fontname");
now set this typeface to your textview
tv.setTypeface(type);
Add this to your activity code:
TextView tv = (TextView) findViewById(R.id.appname);
Typeface face = Typeface.createFromAsset(getAssets(),
"fonts/fontname");
tv.setTypeface(face);
Note that for this you'll have to create a fonts folder at app/src/main/assets

Set different font by default for TextView in Android [duplicate]

This question already has answers here:
How to change the font on the TextView?
(16 answers)
Closed 8 years ago.
I want to set a custom font by default for TextView in android app. Will i need to create custom view for this ? Or is there any other way to do it except for loading it from assets folder and applying them individually?
Is there a way that a custom font can be directly used in xml, just like "sans","serif"
In your asset folder create a folder named fonts and then access it like this :
TextView text = (TextView) findViewById(R.id.textview03);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/YourFile.otf");
text.setTypeface(tf);
First download the .ttf file of the font you need (urfont.ttf). Place it in the assets folder(Inside assest folder create new folder named "fonts" and place it inside it).
Typeface tf = Typeface.createFromAsset(getAssets(),
"fonts/urcustomfont.ttf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setTypeface(tf);
This question has previously been answered:
How to change the font on the TextView?
Default font is Droid Sans. Also can have Droid Sans Mono and Droid Serif. These can be changed through either using setTypeface, or through editing the android:typeface XML
As already stated, you can use custom fonts by the method described by AndroidWarrior but keep in mind licensing issues as well as the performance of your app if you add lots of custom fonts.

How can i use clocktopia font which is already there in my Android Device?

I have a clocktopia font on my android device and it's only on some applications.
How do I use that particular font programmatically?
Thank you.
First, put the .ttf (or other font file) in your /assets directory.
Then, set the font face of your textview with the following code.
TextView textView = (TextView) findViewById(R.id.myTextView);
Typeface font = Typeface.createFromFile("path-to-file");
textView.setTypeface(font);
Unfortunately you cannot use custom typefaces in XML (so you also cannot define a custom theme with your font).
Custom fonts and XML layouts (Android)
You can use the TextViewPlus class provider here to load the typeface from xml but I don't know of a way to use a theme to do this automatically.

Android - Fonts in Application

I have added an external font in /assets directory, and manually doing setFacetype(font).
Isn't there a general way to set the whole application to use a specific font if you have added it external? Or do you have to use Android's selected fonts in order to achieve this?
You cannot use your custom fonts through to whole application in a general way.
You cannot set your custom fonts through xml files.
You have to use the Typeface functions in your code to use your custom fonts within your application.
tv=(TextView)findViewById(res);
Typeface font = Typeface.createFromAsset(this.getAssets(), "MYFONT.TTF");
tv.setTypeface(font);
This also how to use it in a textview.
For whole application go to Using a custom typeface in Android.
and go to Manish Singla answer
Typeface mTypeface = Typeface.createFromAsset(getAssets(), "YOUR FONT NAME");
textview.setTypeface(mTypeface, Typeface.NORMAL);

How to change the Font styles and face in Android?

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);

Categories

Resources