I\'m trying to use fonts in my project using Typeface. I copied the \"font.ttf\"
into a folder named \"fonts\" inside \"assets\" folder. But eclipse do not allo
@ Android studio within Please check this code may be helpful to you
app/src/main/assets/your ttf file.
@ Add this code in activity.
Typeface typeface = Typeface.createFromAsset(getAssets(), ""); txt.setTypeface = (typeface)
@ Add this code in Adapter
Typeface typeface = Typeface.createFromAsset(context.getAssets(), ""); txt.setTypeface = (typeface)
Put your Font File in Assest Folder,
and in use Bellow Code for access.
Typeface tf=Typeface.createFromAsset(getAssets(),"fonts/Century Gothic.ttf");
textview=(TextView)findViewById(R.id.textviewone);
textview.setTypeface(tf);
ttf file is in --> assets/fonts/Century Gothic.ttf
Thank you everybody for answers. But i managed to make it work by doing following
"clean your project with Project menu > clean tab then build your project
If it's still unsolved, configure build path by right click on project > build path > android > restore default
I hope this is helpful"
answer found at Error in Android project name in Eclipse
You should put fonts inside this path
\app\src\main\assets\fonts
[Note : Create a new directory(Folder) inside the assests directory in the above patha i have created ]
Then put your ttf font file inside the fonts directory . You can set your font like this way :
Typeface anyName = Typeface.createFromAsset(Context,"fonts/yourFontFileName.ttf");
simpleTextView.setTypeface(anyName);
Please check this link, it may be helpful to you.
OR
use below code.
Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/LATINWD.TTF");
txt1.setTypeface(tf);
.ttf file is in --> assets/fonts/LATINWD.TTF
Please first clean your project then check again.
Happy Coding.
As of Android Studio 1.5.1 you can:
app
directoryNew
> Folder
(this is near the bottom of the list and is easy to miss) > Assets Folder
Finish
assets
folder