首页 > 代码库 > [Android]Tab

[Android]Tab

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0.0dip"
            android:layout_weight="1.0" />
        <TabWidget 
    		android:id="@android:id/tabs"
    		android:layout_width="fill_parent"
    		android:layout_height="wrap_content"
    		android:layout_weight="0.0"
    		android:visibility="gone"/>
     	<RadioGroup
        	android:id="@+id/radioGroup"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:layout_gravity="bottom"
            android:gravity="left"
            android:background="@drawable/bg_bottom_tab"
            android:orientation="horizontal" >
           	<RadioButton
            	android:id="@+id/homepage"
                style="@style/bottom_tab_style"
                android:drawableTop="@drawable/bg_tab_homepage"
                android:tag="HomePage"
                android:text="@string/HomePage" />
          	<RadioButton
            	android:id="@+id/sell"
                style="@style/bottom_tab_style"
               	android:drawableTop="@drawable/bg_tab_homepage"
                android:tag="Sell"
                android:text="@string/Sell" />
          	<RadioButton
            	android:id="@+id/buy"
                style="@style/bottom_tab_style"
                android:drawableTop="@drawable/bg_tab_homepage"
                android:tag="Buy"
                android:text="@string/Buy" />
          	<RadioButton
            	android:id="@+id/donate"
                style="@style/bottom_tab_style"
                android:drawableTop="@drawable/bg_tab_homepage"
               	android:tag="Donate"
               	android:text="@string/Donate" />
         	<RadioButton
            	android:id="@+id/more"
                style="@style/bottom_tab_style"
                android:drawableTop="@drawable/bg_tab_homepage"
                android:tag="More"
                android:text="@string/More" />
   		</RadioGroup>
    </LinearLayout>
</TabHost>

styles.xml中配置

<style name="bottom_tab_style">
        <item name="android:textSize">15.0dip</item>
        <item name="android:textColor">#ffffffff</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:background">@drawable/selector_radiobutton</item>
        <item name="android:paddingTop">8.0dip</item>
        <item name="android:button">@null</item>
        <item name="android:layout_weight">1.0</item>
        <item name="android:drawablePadding">5.0dip</item>

selector_radiobutton.xml

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

    <item android:drawable="@drawable/bg_tab_radiobutton_s" android:state_enabled="true" android:state_focused="true" android:state_pressed="false"/>
    <item android:drawable="@drawable/bg_tab_radiobutton_d" android:state_enabled="true" android:state_pressed="true"/>
    <item android:drawable="@drawable/bg_tab_radiobutton_d" android:state_enabled="true" android:state_checked="true" />

</selector>














[Android]Tab