Allen Gingrich
Allen Gingrich

Reputation: 5667

Android: Using a nine-patch background on a button, I cannot add any padding around the text

As the title says, I cannot get padding around the text.

Here's my xml:

<style name="StandardButton" parent="@android:style/Widget.Button">
    <item name="android:background">@drawable/nine_patch_3</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:textStyle">bold</item>
    <item name="android:paddingLeft">10dp</item>
    <item name="android:paddingRight">10dp</item>
</style>

Thanks!

Upvotes: 1

Views: 1382

Answers (1)

Konstantin Burov
Konstantin Burov

Reputation: 69238

You can specify paddings through the 9-patch image itself. Draw lines along right and bottom borders of the image. Paddings then will be equal to the size of the lines minus size of the stretch lines (drawn on the left and bottom borders).

Second option: try using 'dip' units instead of 'dp' in your style definition.

Upvotes: 4

Related Questions