Sherlock动作栏改变文字颜色

时间:2012-08-02 10:59:02

标签: android actionbarsherlock

我正在使用sherlock操作栏版本4.1.0 (2012-05-17)。 如何更改此屏幕截图中文本颜色的颜色?在实际设备上,它几乎是可读的

enter image description here

我有这个主题

<style name="MyTheme" parent="@style/Theme.Sherlock.Light">
    <item name="android:textSize">20dp</item> 
</style>

这在AndroidManifest.xml中

<application
        android:name="abc.MyApp"
        android:icon="@drawable/ic_launcher"
        android:logo="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" 
        >

4 个答案:

答案 0 :(得分:3)

实际上我通过执行以下操作设法在abs 4.2中设置了SearchView文本颜色的样式:

<style name="MyTheme" parent="Theme.Sherlock.Light">

    <item name="searchAutoCompleteTextView">@style/Widget.Styled.SearchAutocompleteTextView</item>

    <item name="queryHint">@string/Search</item>
    <item name="android:queryHint">@string/Search</item>


</style>

<style name="Widget.Styled.SearchAutocompleteTextView" parent="Widget.Sherlock.Light.SearchAutoCompleteTextView">
    <item name="android:textColor">YOU_COLOR_HERE</item>

</style>

答案 1 :(得分:1)

我对Sherlock没有任何经验,但您是否尝试添加:

<item name="android:textColor">@color/my_color</item>

到Sherlock动作栏主题?

然后在您的values / color.xml中,您有颜色:

<color name="my_color">#ff00ff00</color>

答案 2 :(得分:1)

感谢这个Answer To: Changing the background drawable of the searchview widget

SearchManager searchManager = (SearchManager) a.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = new android.widget.SearchView(a.getApplicationContext());
int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
// Getting the 'search_plate' LinearLayout.
AutoCompleteTextView searchPlate = (AutoCompleteTextView) searchView.findViewById(searchPlateId);
// Setting background of 'search_plate' to earlier defined drawable.
searchPlate.setTextColor(Color.BLACK);
...

答案 3 :(得分:1)

使用这个,这是对的。 :d

AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(color.black));
searchText.setTextColor(getResources().getColor(color.black));