Answer the question
In order to leave comments, you need to log in
How to change default theme font to custom font in Android Studio?
In the most default application theme, which is automatically applied in Android Studio for each new project, a blue panel with the name of the application is displayed on top, under the status bar. How can I edit the font on this panel?
Answer the question
In order to leave comments, you need to log in
Reflection to help:
https://stackoverflow.com/questions/2711858/is-it-...
The Typeface class has standard fonts defined, it is enough to override the desired values and you will be happy.
public class Typeface {
...
/** The default NORMAL typeface object */
public static final Typeface DEFAULT;
/**
* The default BOLD typeface object. Note: this may be not actually be
* bold, depending on what fonts are installed. Call getStyle() to know
* for sure.
*/
public static final Typeface DEFAULT_BOLD;
/** The NORMAL style of the default sans serif typeface. */
public static final Typeface SANS_SERIF;
/** The NORMAL style of the default serif typeface. */
public static final Typeface SERIF;
/** The NORMAL style of the default monospace typeface. */
public static final Typeface MONOSPACE;
...
}
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.Toolbar>
Typeface typeface = Typeface.createFromAsset(context.getAssets(), fontAssetName);
TextView toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
toolbarTitle.setTypeface(typeface);
Android O will have the ability to use custom fonts.
The 26.0.0 Beta 1 Support Library release backports this behavior.
So you can play with it and do it normally, without reflection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question