AndroidManifest.xml
android:theme="@style/AppTheme"
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:fontFamily">@font/montserrat</item>
<item name="fontFamily">@font/montserrat</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
activity_dashboard.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include layout="@layout/content_dashboard" />
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/background_top_right_radius_white"
android:fitsSystemWindows="false"
app:headerLayout="@layout/nav_header">
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_160sdp"
android:divider="@color/white"
android:dividerHeight="0dp"
android:groupIndicator="@null" />
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
content_dashboard.xml (Only sharing the textview code)
<TextView
android:id="@+id/tvDashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_45sdp"
android:layout_marginTop="@dimen/_10sdp"
android:text="@string/dashboard"
android:textColor="@color/black"
android:textSize="@dimen/_20sdp"
android:textStyle="bold" /> //this is not working
Dashboard.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
TextView tvDashboard = findViewById(R.id.tvDashboard);
tvDashboard.setTypeface(null, Typeface.BOLD); //this is not working
}
The entire app font has been set to Montserrat using https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts#via-android-studio. However, in some parts I have headings and such so I would like to change the style to bold. It is working in some places when I'm using the setTypeface code, but it isn't working in other places (including the above example). That is odd and I'm not sure why it is behaving this way.