How to change the text on the pressed button?

I want to move the text on the pressed button a bit. In my case, the button has a custom background, and the button will look much better if the text is shifted.

I made two NinePath images with different pads:

enter image description here

enter image description here

And set them using the selector:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/btn_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/btn"/>

</selector>

This does not work, the text remains in place when the button is pressed (and the background is replaced).

Are my NinePath snapshots OK? Is there a way to shift text without installing touch listeners?

PS The same question has already been asked, but the "answer" is exactly the solution I tried: https://stackoverflow.com/a/316618/

+3
source share
2 answers

9-- . , , , .

Button .

+1

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:text="Pressed state text" android:state_pressed="true"/>
    <item android:text="Default text"/>

</selector>
0

All Articles