In this tutorial, you will learn how to make Android TextView bold. There are 4 ways in this tutorial, you can easily learn, adapt the code and use it in your project as you like. Let’s start.

Way 1 – make Android TextView bold using android:textStyle attribute

android:textStyle attribute is the first and one of the best way to make the text in TextView bold. just use “bold”.

If you want to use bold and italic. Use pipeline symbol “|” . just like this “bold|italic”.

Way 2 – make Android TextView bold using setTypeface() method

TextView has a method called setTypeface() which needs

  1. Typeface
  2. Int styleflag

In our case, leave Typeface as null, use styleflag Typeface.BOLD.

textview2.text= "TEXTVIEW 2"

You can use Typeface.ITALIC for italic style.

Way 3 – make Android TextView bold using Html.fromHtml() method

The fromHtml() method returns displayable styled text from given Html string. Using this advantage, we can make our text in TextView bold.

val html = "This is TEXTVIEW 3"
textview3.text = Html.fromHtml(html)

Html.fromHtml(String source) was deprecated in API level 24. Use androidx.core.text.HtmlCompat instead. For using HtmlCompat, you need to include dependency in your project.

implementation 'androidx.core:core:1.0.1'

If you got Manifest merger failed error, then add below code in


        val html = "This is TEXTVIEW 3"
        textview3.text = HtmlCompat.fromHtml(html,HtmlCompat.FROM_HTML_MODE_LEGACY)

HtmlCompat.FROM_HTML_MODE_LEGACY – It just adds two newline character between block level elements.

Way 4 – Make Android TextView Bold using separate style

In this example, we create a separate style resource and set it to our TextView. The advantage of this technique – you can use this style for many TextViews. Just specifying style attribute.

Step 1

Create a separate style resource named “boldStyle”, add “android:textStyle” as item and provide value “bold”.


Step 2

Set style to TextView using style attribute.

Let’s create an Android app with these examples. Open your Android Studio,

Step 1

Start a new Android Studio project

Application name: TextView Bold – Kotlin

Company domain:

check to include Kotlin support.

Step 2

Select minimum SDK: API 15 – Android 4.0.3 (Ice Cream Sandwich) and click Next.

Next dialog, Select Empty Activity and click Next.

Activity Name: MainActivity
Check Generate layout file

Layout Name: activity_main

Click Finish.

build.gradle(Project: TextView Bold – Kotlin)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
    dependencies {
        classpath ''
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

allprojects {
    repositories {

task clean(type: Delete) {
    delete rootProject.buildDir

build.gradle(Module: app)

apply plugin: ''

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.androidride.textviewbold_kotlin"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation ''

    testImplementation 'junit:junit:4.12'
      implementation 'androidx.core:core:1.0.1'

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":




    TextView Bold Example











package com.example.androidride.textviewbold_kotlin

import android.os.Bundle
import androidx.core.text.HtmlCompat

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?)

        //Make textview bold - programmatically
        textview2.text= "TEXTVIEW 2"

        //Using fromHtml() method
        val html = "This is TEXTVIEW 3"
        textview3.text = HtmlCompat.fromHtml(html,HtmlCompat.FROM_HTML_MODE_LEGACY)



Run Now

android textview bold example - android set text bold
android textview bold

If you find anything useful, please share it.
Thank you.

Please disable your adblocker or whitelist this site!