Custom font in TileService UI - android

In TileService for font style we have to use LayoutElementBuilders.FontStyle to change font style. But in
LayoutElementBuilders.FontStyle.Builder and LayoutElementBuilders.Text class I can't see any method for custom font.
Is TileService new UI Builder api support custom font?
How can i set custom font in TileService UI ?

It's not a supported feature. Tiles are rendered in a different process, so don't automatically have the same fonts.
See https://github.com/android/wear-os-samples/issues/153
Setting custom fonts in tiles is not allowed as tiles are rendering in a system context and so there are security concerns with loading fonts into a privileged process.

Related

Android Settings app - Default font sizes used for titles and subtitles

What font sizes are used by default in the Settings app for the titles and subtitles? The option in the red rectangle is an example.
If there even is a recommendation, I suppose it would be to use the default sizes used by the Jetpack Preferences library. These use
?android:attr/textAppearanceListItem
and
?android:attr/textAppearanceListItemSecondary
so it is pulling the text styles from the theme. In the latest Material Components theme, if you follow the chain of references all the way up to what font sizes they are using by default, they are 16sp for the title and 14sp for the summary.

How to make an app font fixed and not to be changed by phone's custom fonts?

I created an app in android 3.0.1
I used Segoe UI light font as default for overall app.
Now when I tested in different phones.
I found a problem that in case if my phone's font is customized with different font style.
That font also affect my app's UI font.
That causes me more UI collapse in my app due to custom phone font.
Please help me to make my app's font fixed and not to be changed by phone's custom font.
Thanks in advance.
Use a custom typeface and set your views texts to that typeface. As you will be putting the font file in your app structure, it should solve your problem. Reference:
How to use custom font in Android Studio
So the way to do that is to override the View you want a custom font for, and progmmatically set the Typeface in the constructor. E.G. for a TextView
public CustomFontTextView extends TextView{
public CustomFontTextView(final Context context, final AttributeSet set){
super(context, set);
this.setTypeface(fetchTypeFace());
}
protected Typeface fetchTypeFace(){
return Typeface.createFromAsset(resources.getAssets(),"your_font.ttf"));
}
}
you can integrate this easy to use custom font library Calligraphy and assign a custom font to your application OR you can use downloadable fonts from latest Android documentation, using the Calligraphy library is the easiest way of setting your app's custom font across all phones even with custom ROMS

Default font in pre-lollipop devices when using appcompat widgets in Android

I understand that that Material design enforces Roboto by default when you load san-serif fonts in the UI widgets.
I also understand in order to render material design in pre-lollipop one needs appcompat UI widgets.
Do this imply that these appcompat UI widgets will render Roboto in pre-lolipop devices as well?
No, the font on pre-L is not Roboto.
you can use Libraries such as RobotoTextView, which is quite nice and easy to use, to set all of your text widgets to Roboto.

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.

how to set the DEFAULT system font in android app?

Can I set the default font which is bydefault set in android app irrespective of which font user has selected???
Thanks in advance
As a developer there is no easy way to use a specific font in every screen of your app.
You have to set your custom font on each and every UI element. This is explained here.
Alternatively you can use this CustomFont helper class to change every UI elemnt for you.

Categories

Resources