I have a TransitionDrawable. The two states are both nine patches and have a content area defined. The problem is the margin is just way too high - in fact it's basically twice as much as it should be. It seems like it's adding up the margins of the two nine patches.
The margin works as it's supposed to work if I set one of those ninepatches directly as a background and not use the TransitionDrawable, so the nine patch is definitely correct.
Has anybody encountered a problem like this?
EDIT: If I set the content area to the full size of the asset and define the padding in xml it works. OTherwise it'll always get the margin wrong. It seems like a bug in Android, so that seems to be the only solution, but maybe there's a nicer way to work around this :/
Yep, you're right. Annoying indeed.
As you've proposed, I use the hard-coded negative paddings to compensate first_nine_patch
's 9-patch padding so far.
<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/first_nine_patch" />
<item android:drawable="@drawable/second_nine_patch"
android:top="-7dp"
android:right="-16dp"
android:bottom="-8dp"
android:left="-4dp" >
</item>
</transition>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With