Something you could do in your work:
private TabHost mTabHost ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mTabHost.setup();
WebView wv = new WebView(this);
setupTab(wv, "My Title");
}
private void setupTab(final View view, final String tag) {
View tabview = createTabView(mTabHost.getContext(), tag);
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(new TabContentFactory() {
public View createTabContent(String tag) {return view;}
});
mTabHost.addTab(setContent);
}
private static View createTabView(final Context context, final String text) {
View view = LayoutInflater.from(context).inflate(R.layout.layout_tabwidget_custom, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(text);
return view;
}
In R.layout.layout_tabwidget_custom:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/selector_tab_bg"
android:gravity="center"
android:orientation="vertical"
android:padding="10dip" >
<TextView
android:id="@+id/tabsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textColor="@drawable/selector_tab_text"
android:textSize="15dip" />
</LinearLayout>
source
share