I have a button on which text need to be aligned at center horizontally. Gravity works fine when the button is without the 9 Patch as a background. But as soon I add a 9 patch as a back ground the gravity shifts towards left and text refuses to budge no matter what gravity is set to.
I have tried setting padding to 0dip, -1px, @null as suggested on some other threads. None of them worked. I am changing background from within the code also using setBackgroundResource() as my requirements are pinned to API level 8, so other methods to set background is not an option. Also I can’t use selector list to do this because I need that button to be in selected state (Like a toggle button).
Any inputs ?
I had to set padding to 0 after each time I set background, programmatically ! That solved my problem.
Thanks