2012-02-29 224 views
0

好吧,我正在尋找一種方法能夠改變,當你點擊的Android TabView的 選項卡上,改變橙色邊框顏色圍繞一個搜索欄顯示的橙色... anyideas如何做這樣的事情?更改TabView的默認顏色和搜索欄默認顏色

這就是我的主標籤查看

<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: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" /> 
    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:background="@drawable/gradient_bg" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 
</LinearLayout> 

和我有這對我的搜索欄

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/searchText" 
     android:hint="@string/Search" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"/> 

    <ImageButton 
     android:id="@+id/searchButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/Search" 
     android:src="@drawable/search" 
     android:onClick="search"/> 

</LinearLayout> 

<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:listSelector="@drawable/list_selector" /> 

任何想法? 非常感謝您的幫助!

回答

0

您需要使用主題。您可以在res/values中設置style.xml,並從Holo繼承並覆蓋所需的屬性。我這樣做對標籤的操作欄中:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<!-- the theme applied to the application or activity --> 
<style name="Theme.Mine" parent="android:style/Theme.Holo"> 
    <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item> 
    <item name="android:actionDropDownStyle">@style/MyDropDownNav</item> 

    <item name="android:selectableItemBackground">@drawable/ad_selectable_background</item> 
    <item name="android:popupMenuStyle">@style/MyPopupMenu</item> 
    <item name="android:dropDownListViewStyle">@style/MyDropDownListView</item> 
    <item name="android:listChoiceIndicatorMultiple">@drawable/ad_btn_check_holo_light</item> 
    <item name="android:listChoiceIndicatorSingle">@drawable/ad_btn_radio_holo_light</item> 
</style> 


<style name="MyActionBarTabStyle" > 
    <item name="android:background">@drawable/actionbar_tab_bg</item> 
    <item name="android:textColorHighlight">#FF5555</item> 
    <item name="android:paddingLeft">10dip</item> 
    <item name="android:paddingRight">10dip</item> 
</style> 

    <style name="TableCellStyle" parent="Theme.Mine"> 
     <item name="android:textColor">#000000</item> 
    <item name="android:textSize">15sp</item> 
    </style> 
</resources> 

然後你就可以在你的清單文件中引用這個主題。你可以在這裏閱讀所有關於它:http://developer.android.com/guide/topics/ui/themes.html

+0

好吧,我明白你要去那裏,但即時通訊使用android 2.1你有一個Tab主題,我可以使用? HOLO不存在爲Android 2.1 – FirstLaw 2012-03-01 17:40:43

+0

另外我只想改變背景和惱人的橙色當你選擇的東西的顏色... – FirstLaw 2012-03-01 17:49:32

+0

我會把這個權利,因爲它適用於更高版本的機器人,感謝您的全力幫助,我終於徹底解決了這個問題。以不同的方式 – FirstLaw 2012-03-15 18:50:33