2013-10-25 3 views
0

В моем приложении я использую вкладки, по умолчанию это выглядит следующим образом:Индикатор выбора Tab

enter image description here

и теперь, я хочу, чтобы показать другой цвет [как: темно-синий] для выбранной вкладки в округлый угловая форма

Я использую ниже XMLs создать над вкладками

используя это, чтобы создать закругленные выступы формы, с белым углом, 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> 

и использовать это, чтобы показать изображение в Tabs, 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> 

ответ

1

проблема может быть здесь: -

<?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> 

попробуйте использовать другое изображение здесь: -

<item android:drawable="@drawable/birthday_text" 
      android:state_selected="true" /> 
Смежные вопросы