if (android: padding), it overrides all other values โโof the else if pad (android: paddingXXX), it overrides bg drawable paddingXXX (XXX = Left | Right | Top | Bottom) else if (view has drawable bg) indent values โโfrom of this drawable (nine patches in your case); otherwise, the default addition (usually zero) is applied
So do not use android: padding = "2dp". the padding property overrides everything. Just use paddingLeft = 20dp, paddingTop = 2dp, paddingRight = 2dp, paddingBottom = 2dp.
Or you can set paddingLeft = 20dp, and other padding values โโwill be taken from bg drawable.
source share