How to Make Android TextView Text Bold

Make Android TextView Text Bold

In order to make the text of TextView bold, we can make use of the XML attribute textStyle with a value as bold,


Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="My Text"
        android:textAlignment="center"
        android:textStyle="bold"
        android:id="@+id/myTextView"/>
</LinearLayout>


You may also achieve this programmatically by using the method setTypeface,

TextView textView = findViewById(R.id.myTextView);
Typeface bold = Typeface.defaultFromStyle(Typeface.BOLD);
textView.setTypeface(bold);

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!