Use weathericons.io in Android? - android

This is a pack of free weather icons that I like.
It's made for CSS/HTML.
How can I type out those special characters in a textview? f00d, f02e etc

Yes, you can use a custom font for that icon pack.
Check any related tutorial about using a custom font in android, or this thread for example.
Also you can use a dedicated library like Calligraphy.

Related

How to custom Edittext android like caculator?

I develop a calculator application and I want customize my EditText like digital number in this picture:
What should I do? Thanks
You would need to find a font matching the one you are looking for (just search for digital font tff files) and apply that font. How to do that can be found here.
You need make the elevation and circle corner of Button,Try Defining Shadows.And also the specific font or image instead to custom the digital number.

Android - What is the best way to use a custom font application wide

I want to use Google's Raleway font in my android app. I have read a lot of blogs and a number of answers on stackOverflow but haven't found the exact answer.
The best answer i found is here that explains to create custom TextViews efficiently.
If i have two use two variations of the font say Raleway-Regular and Raleway-SemiBold, do i have to create two custom TextViews or is there any better way to achieve that ?
I have done the task the following way
Download the ttf of that font and then paste it inside the asset folder(you have to create the assets folder inside /src/main/assets)
then change the font the following way:
Typeface face = Typeface.createFromAsset(getAssets(), "condenced.ttf");
tv_the.setTypeface(face);
you can download the multiple ttf files and can display the different fonts to different fields.
Hope this helps.
I am using Calligraphy library for my project and it works perfect.
For me the best way to use a custom font is this library:
Calligraphy

Default custom font

Is it possible to set a custom font as default in a android application? Because typing this for every TextView is not efficient.
login = (TextView)findViewById(R.id.tvLogin);
login.setTypeface(titleFont);
Is it possible to set a custom font as default in a android application?
Not for a custom Typeface that you loaded from your own font file, sorry. As others have noted, there are workarounds and libraries to help simplify matters a bit. Personally, I'd look at Calligraphy or perhaps Fontify.

Getting All Views has text on Android layout for setting custom font. What is the Best Practice?

I need to get all views that have text for setting custom fonts.
I can develop a recursive method in myBaseActiviy class for getting all views with checking instanceof when programme is in OnCreate(). But I worry about the performance? I interest your idea? What should I do?
There is no best way. An approach, the one I use, is to subclass TextView, adding a new attribute to specify the font I want to use, delegating the logic to the subclass self.
I think the easiest way is to create your own TextView. It's not as hard as it sounds ;-).
This is the origional answer:
https://stackoverflow.com/a/19679639/2767703
And this is the link you'll need:
http://javatechig.com/android/using-external-fonts-in-android-view
Or if you want to set the font in the xml:
https://stackoverflow.com/a/7197867/2767703
Warning
If you are developing for Android versions lower than Android 4.0 then
you should change the code. In these versions there is a bug that
doesn't free up memory for typefaces. What you should do is create a
HashMap that allows reusage of Typefaces. You can find more in the
comments of the last link (search for the comment with the highest
upvote).
You could also use this:
https://stackoverflow.com/a/16883281/2767703
This changes the font of every text in your application. Note: You still have to look at my warning if you use this.
You can do something like this:
Add new attribute for store font in style.
Extend your view to handle this attr and set font by view when do you need.
You can find example of using and creation of new attribute for font at this link https://stackoverflow.com/a/12282315/2156937
Hope it helps.

Supporting custom text weight in Android

Is there a way to support more than standard three available text weights in Android. I need to have five: ExtraLight, Light, Normal, Medium and Bold.
I saw this question: How to change fontFamily of TextView in Android, but it related to family rather than weight.
If there is no in-build support, maybe any external resources or libraries are available?
As I am not aware of how a library could add support for your font without including it, I would advise you to create your own implementation of TextView to handle that, it can be done quite quickly, if you only need it for TextView (you would need to implement your own EditText as well if you need that widget).
You can start by looking at the RobotoTextView library which allows for the RobotoTextView widgets to be used in code as well as directly in xml, using attributes.

Categories

Resources