Android Button – Text Size or Font Size

Change Text Size in Buton

To change the text or font size in Button widget, set the textSize attribute for Button with required dimensions.

Button textSize in XML Layout

<Button
    android:textSize="20sp"
    android:text="Submit" />

<Button
    android:textSize="30sp"
    android:text="Submit" />

<Button
    android:textSize="40sp"
    android:text="Submit" />
Android Button - Text Size or Font Size

Example

Create an Android Application with Kotlin support and Empty Activity. Create three Button widgets with different text sizes: 20sp, 30sp and 40sp respectively. You would observe how the Button text/font size changes.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button_id_1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:paddingHorizontal="40dp"
        android:textAllCaps="false"
        android:background="#0789C5"
        android:textColor="#FFF"
        android:textSize="20sp"
        android:text="@string/submit" />
    <Button
        android:id="@+id/button_id_2"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:paddingHorizontal="40dp"
        android:textAllCaps="false"
        android:background="#0789C5"
        android:textColor="#FFF"
        android:textSize="30sp"
        android:text="@string/submit" />
    <Button
        android:id="@+id/button_id_3"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:paddingHorizontal="40dp"
        android:textAllCaps="false"
        android:background="#0789C5"
        android:textColor="#FFF"
        android:textSize="40sp"
        android:text="@string/submit" />

</LinearLayout>

MainActivity.kt

package com.kotlinandroid.myapp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

Screenshot

Android Button - Text Size or Font Size