jonhobbs jonhobbs - 1 year ago 129
Android Question

Android button font size

I;ve been trying to create a custom button in android using this tutorial -

It works well but it doesn't say how to change the font size or weighting. Any ideas?

There was another question on here and the only answer was to use html styling but you can't change a font size in html without using css (or the deprecated font tag). There must be a better way of setting the pixel size of the font used on buttons?

Answer Source

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

<Button android:id="@+id/next_button"
            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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download