Friday, January 9, 2015

How to set Button text style bold and italic 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 Style Default"
 android:textSize="40sp"
 />
<Button
 android:id ="@+id/push_button2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button - Bold Text"
 android:textSize="40sp"
 android:textStyle="bold"
 />
<Button
 android:id ="@+id/push_button3"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button - Italic Text"
 android:textSize="40sp"
 android:textStyle="italic"
 />
<Button
 android:id ="@+id/push_button4"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button - Bold Italic Text"
 android:textSize="40sp"
 android:textStyle="bold|italic"
 />
More android examples