Question

I have problem with padding in StateListDrawable. If for some in my styles i define reference on some <selector> with image resources, it set some wrong padding for my 9path images. By the way i set particular image - all is ok. But otherwise, android create StateListDrawable for my <selector> and (as i saw by using debugger on sources) it get padding by use method:

Rect getConstantPadding();

and return wrong values (in my case it not null or 0). This method use mVariablePadding variable:

if (mVariablePadding) {
     return null;
}

But i can't set it false in resources (maybe i did something wrong).

Does someone know solution for this problem? Thanks!

Was it helpful?

Solution

The problem was in 9-path images. For selector it calculate padding from right-bottom border (content) of nine-path drawable. Beside there is variables in selector android:variablePadding, that calculate that padding (choose the biggest, etc). So it can be still non 0, even if in mostly cases images doesn't have padding.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top