I'm trying to set a custom background for the tabs in my TabWidget. They're pretty much all just a bunch of rectangle shape gradients, but I found out that by setting the background drawables, it removes the default divider between each tab. To remedy this, I used a layer-list drawable to layer a divider on top of the tabs. However, now, it's affecting the layout of th开发者_开发知识库e tab itself, causing the image and text label to move apart.
Intended result
What I get by using a layer-list for the backgroundI'm just using this to setup the backgrounds:
TabWidget tw = mTabHost.getTabWidget();
for (int i = 0; i < tw.getChildCount(); i++) {
View v = tw.getChildAt(i);
v.setBackgroundDrawable(getResources().getDrawable (R.drawable.tab_background));
}
Any clues as to why this is happenings, or suggestions on what else I can do instead?
It seems that using the layer-list as a background reset the all of the paddings within the view to 0. A bit non-sensical, considering a background drawable conceptually shouldn't affect any of this stuff, but whatever, I suppose. Saving the previous paddings and setting them back to what they were before fixes the problem.
精彩评论