Android button font size Android button font size android android

Android button font size


You define these attributes in xml as you would anything else, for example:

<Button android:id="@+id/next_button"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="@string/next"            android:background="@drawable/mybutton_background"            android:textSize="10sp" /> <!-- Use SP(Scale Independent Pixel) -->

You can find the allowed attributes in the api.

Or, if you want this to apply to all buttons in your application, create a style. See the Styles and Themes development documentation.


Button butt= new Button(_context);butt.setTextAppearance(_context, R.style.ButtonFontStyle);

and in res/values/style.xml

<resources>       <style name="ButtonFontStyle">            <item name="android:textSize">12sp</item>    </style></resources>


Programmatically:

Button bt = new Button(this);bt.setTextSize(12);

In xml:

<Button    android:textSize="10sp"/>