自定义TabActivity样式



public class TManageTab extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
    tabHost = getTabHost();
tabHost.addTab(tabHost
.setIndicator(createTabIndicatorView(R.string.system_contact, TAB_INDEX_MOBILE))
}
//自己定义TabActivity显示页View
private View createTabIndicatorView(int title, int index) {
       View v = LayoutInflater.from(this).inflate(R.layout.contact_email_tab,null);
      text);
      
      image);
       switch (index) {
       case 0:
          tab1);
           break;
       case 1:
          tab2);
           break;
      
       return v;
}


image_tab1.xml


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">





   android:drawable="@drawable/tab_1_press"

   android:drawable="@drawable/tab_1_press"


</selector>


text_tab_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
   <item android:color="#A2D251" android:state_pressed="true" />
   <item android:color="#A2D2501" android:state_selected="true" />
   <item android:color="#A2D251" android:state_checked="true" />
   <item android:color="#A2D251" android:state_focused="true" />
   <item android:color="#FFF" />
</selector>
contact_email_tab.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="@drawable/email_bg"
   android:orientation="vertical" >
   <LinearLayout
       android:id="@+id/linearLayout1"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_margin="2dp"
       android:background="@drawable/email_bg1 "
       android:gravity="center"
       android:orientation="vertical"
       android:padding="1dp" >
       <ImageView
           android:id="@+id/image"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           >
       </ImageView>
       <TextView
           android:id="@+id/text"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           android:textColor="@color/text_tab_color" >
       </TextView>
   </LinearLayout>
</LinearLayout>
 如果要将TabActivity  页卡放到屏幕底部  需自定义布局文件
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@android:id/tabhost"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >
   <LinearLayout
       android:id="@+id/tabout"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="vertical" >
       <RelativeLayout
           android:id="@+id/relativeLayout1"
           android:layout_width="wrap_content"
           android:layout_height="fill_parent"
           android:layout_weight="1" >
           <FrameLayout
               android:id="@android:id/tabcontent"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:paddingTop="0dip" >
           </FrameLayout>
       </RelativeLayout>
       <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="56dp" />
   </LinearLayout>

</TabHost>