I wanted to see if anyone has had success with customization of tabs using FragmentTabHost that comes with the new Android API level 17.
I was excited to be able to
I think, it was a mistake to set method initFragmentTabHost() to constructor. At that time TabHost don't his children - it happens after. LinearLayout, for example, work with his children in onMeasure() method (grepcode). ViewGroup in constructor just init variables, and set mChildrenCount = 0 (grepcode).
All what I can did, it's only costumize FragmentTabHost:
And costumize Tabs (have problems with tab heights, I solve them in code):
In code:
tabSpec = mTabHost.newTabSpec(tag).setIndicator(createTab(caption));
...
private View createTab(CharSequence title) {
final View v = View.inflate(getActivity(), LAYOUT_TAB, null);
((TextView) v.findViewById(android.R.id.title)).setText(title);
return v;
}
I think other customization with TabWidget we can do only with programmatically manipulating, like this:
final View tabs = (TabWidget) mTabHost.findViewById(android.R.id.tabs);
final ViewGroup parent = (ViewGroup) mTabHost.getChildAt(0);
parent.removeView(tabs);
parent.addView(tabs);
IMHO, this is not good.