I need to create a specific shape for the Tab. It should look like this

Is is possible to create it via shape? Or just to use it as an image?
I also saw that some people use this way when they have to create very specialized tabs: they simply create all variants of all tabs in photoshop, selected and unselected, (for example,tab1_selected, tab1_unselected,...), but they do not create images for each tab, but literary they create the whole TabWidget image (for example, image with tab1 selected, and other tabs unselected) and then they load the appropriate image when certain tab is selected.
background attribute or some other way?Use the following code and the MyClass in code is the ClassName in which the code is written:
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
MyClass.setTabColor(tabHost);
}
});
public static void setTabColor(TabHost tabhost) {
for(int i=0;i<tabhost.getTabWidget().getChildCount();i++) {
tabhost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_bg); //unselected
}
tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundResource(R.drawable.tab_bg_selected); // selected
}
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