Android Question Custom Font

Blueforcer

Well-Known Member
Licensed User
Longtime User
I want to change the whole font of my app from native Roboto do something else. im Using a android 7 and 8 device
i found this Tutorial
i needed to change CustomFontStyle to custom_font otherwise i was getting the error:
res\values\theme.xml:8: error: resource font/CustomFontStyle (aka de.dinotec.netplus:font/CustomFontStyle) not found.

With this it compiles without an error message, but the Font is still the same, even after resinstalling and project cleaning.
What im doing wrong? what is "Support Library 26"?

B4X:
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
         <item name="android:fontFamily">@font/custom_font</item>
        <item name="fontFamily">@font/custom_font</item>
    </style>
</resources>
)

CreateResource(font, custom_font.xml,
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:app="http://schemas.android.com/apk/res-auto">
    <font android:fontStyle="normal" android:fontWeight="400" android:font="@font/mulish"/>
    <font android:fontStyle="italic" android:fontWeight="400" android:font="@font/mulish" />
    <font app:fontStyle="normal" app:fontWeight="400" app:font="@font/mulish"/>
    <font app:fontStyle="italic" app:fontWeight="400" app:font="@font/mulish" />
</font-family>
)
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
With this it compiles without an error message, but the Font is still the same, even after resinstalling and project cleaning.
What im doing wrong? what is "Support Library 26"?

For API level 26 or lower use the app namespace to ensure your fonts load.

app namespace = package name

1758209147873.png
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
I am currently experimenting / guessing with chatgpt and have at least gotten to the point where Msgboxen and CSbuilder accept a new font (without explicitly setting one in code). But here, too, the title is missing, and the rest of my app still has the standard font.

But only if im adding:
B4X:
#Extends: android.support.v7.app.AppCompatActivity

B4X:
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
         <item name="android:fontFamily">@font/rubik</item>
        <item name="fontFamily">@font/rubik</item>
       <item name="android:textViewStyle">@style/AllTextViews</item>
    </style>
   
    <style name="AllTextViews" parent="@android:style/Widget.TextView">
        <item name="android:fontFamily">@font/rubik</item>
        <item name="fontFamily">@font/rubik</item>
    </style>
</resources>
)

1758263099475.png
 
Upvote 0
Top