Friday, January 9, 2015

How to set Button text size in Android

activity_main.xml code snippet

<Button
 android:id ="@+id/push_button"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button Text Size - Default"
 />
<Button
 android:id ="@+id/push_button2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button Text Size - 40SP (Scale-Independent-Pixels)"
 android:textSize="40sp"
 />
<Button
 android:id ="@+id/push_button3"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button Text Size - 40DP (Density-Independent-Pixels)"
 android:textSize="40dp"
 />
<Button
 android:id ="@+id/push_button4"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button Text Size - 0.30 Inches"
 android:textSize="0.30in"
 />
<Button
 android:id ="@+id/push_button5"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button Text Size - 25pt (Points)"
 android:textSize="25pt"
 />
<Button
 android:id ="@+id/push_button6"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button Text Size - 6 Millimeters"
 android:textSize="6mm"
 />
More android examples