系统自定义的TabWidget(居于底部)---附源码

android:layout_alignParentBottom="true"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@+id/tabhost"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/tab1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical">
<TextView android:id="@+id/view1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="tab1" />
</LinearLayout>
<LinearLayout android:id="@+id/tab2"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical">
<TextView android:id="@+id/view2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="tab2" />
</LinearLayout>
<LinearLayout android:id="@+id/tab3"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical">
<TextView android:id="@+id/view3" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="tab3" />
</LinearLayout>
<LinearLayout android:id="@+id/tab4"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical">
<TextView android:id="@+id/view4" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="tab4" />
</LinearLayout>
</FrameLayout>
</RelativeLayout>
</TabHost>
</LinearLayout>
Main.java
public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setTitle("TabWidget居于底部");
setTitleColor(Color.YELLOW);
Resources res = getResources();
TabHost tabhost = (TabHost) findViewById(R.id.tabhost);
tabhost.setup();
TabHost.TabSpec spec = tabhost.newTabSpec("tab1");
spec.setContent(R.id.tab1);
spec.setIndicator("待办", res.getDrawable(R.drawable.menu_1));
tabhost.addTab(spec);
spec = tabhost.newTabSpec("tab2");
spec.setContent(R.id.tab2);
spec.setIndicator("公告", res.getDrawable(R.drawable.menu_2));
tabhost.addTab(spec);
spec = tabhost.newTabSpec("tab3");
spec.setContent(R.id.tab3);
spec.setIndicator("邮件", res.getDrawable(R.drawable.menu_3));
tabhost.addTab(spec);
spec = tabhost.newTabSpec("tab4");
spec.setContent(R.id.tab4);
spec.setIndicator("设置", res.getDrawable(R.drawable.menu_4));
tabhost.addTab(spec);
tabhost.setCurrentTab(0);
}
}