私のアプリではタブを使用しています。デフォルトでは次のようになります。
そして今、選択したタブに別の色 [like:dark blue] を角の丸い形で表示したい
以下の XML を使用して上記のタブを作成しています
これを使用して、角が白い mytab_custom.xml の丸い形状のタブを作成します。
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#44b8ec"/>
<stroke android:width="1dp"
android:color="#ffffff" />
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp" />
</shape>
これを使用して、タブに画像を表示するには、tab_contact.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/birthday_text"
android:state_selected="true" />
<item android:drawable="@drawable/birthday_text" />
</selector>
tab_indicator.xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dip"
android:layout_height="40dip"
android:layout_weight="1"
android:orientation="vertical"
android:padding="5dp">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/icon"
/>
</RelativeLayout>
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"
android:background="@drawable/btn_background"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/check"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>