更改TabView的默认颜色和搜索栏默认颜色

问题描述:

好吧,我正在寻找一种方法能够改变,当你点击的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" /> 

任何想法? 非常感谢您的帮助!

您需要使用主题。您可以在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