Reputation: 198188
I defined a drawable in xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<padding
android:bottom="1dp"
android:left="0dp"
android:right="0dp"
android:top="5dp" />
<corners
android:bottomLeftRadius="0.1dp"
android:bottomRightRadius="0.1dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />
</shape>
And use it in layout xml:
<RelativeLayout
style="@style/TabHeader"
android:background="@drawable/_moremsg_tab_back" >
<TextView
android:id="@+id/text"
style="@style/TabText"
android:text="TODO" />
</RelativeLayout>
The effect is (the first tab):
When click the other tabs, I add the drawable as their background by code:
v.setBackgroundDrawable(getResources().getDrawable(R.drawable._moremsg_tab_back));
But it displays different as the first one:
How to fix it?
Upvotes: 0
Views: 901
Reputation: 1691
I believe padding is removed when you set a drawable in code.
I know its not what you want to hear but this is an android bug. There are ways around it, but nothing clean.
See this question: Where'd padding go, when setting background Drawable?
Upvotes: 2