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:


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/
source
share