如何改变自动完成文本颜色搜索查看ActionBarSherlock内与黑暗的背景? [英] How to change the autocomplete text color for search view inside of ActionBarSherlock with dark background?

查看:280
本文介绍了如何改变自动完成文本颜色搜索查看ActionBarSherlock内与黑暗的背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我自己的主题ActionBarSherlock根据 Theme.Sherlock.Light.DarkActionBar ,这里有我的风格:

I have my own theme for ActionBarSherlock based on Theme.Sherlock.Light.DarkActionBar, here are my styles:

<style name="Theme.MyTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>

<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@drawable/action_bar</item>
    <item name="background">@drawable/action_bar</item>
</style>

其中, @绘制/ action_bar 是一个xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/color_action_bar_bottom_line" />
        </shape>
    </item>

    <item android:bottom="2dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/color_action_bar_background" />
        </shape>
    </item>
</layer-list>

一切都看上去很不错,除了一件事:在搜索查看文本(当我使用在动作条搜索模式)是黑暗的黑暗,所以我什么都看不到。我试图设置文本颜色搜索查看手动:

Everything looks great except one thing: the text in the SearchView (when I use the search mode in ActionBar) is "dark on dark", so I cannot see anything. I tried to set the text colors for SearchView manually:

AutoCompleteTextView searchTextView =
        (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchTextView.setTextColor(Color.WHITE);
searchTextView.setHintTextColor(Color.LTGRAY);
searchTextView.setHighlightColor(Color.WHITE);
searchTextView.setLinkTextColor(Color.WHITE);

这帮助了很多,但我不能改变自动填充文本的颜色:

This helped a lot but I cannot change the color of autocomplete text:

正如你看到的,依旧是黑色的。如何设置白色文本颜色为这种文字?

As you see, it's still black. How can I set the white text color for this kind of text?

推荐答案

我解决了这个通过禁用自动完成功能(它会被禁用,如果你设置编辑类型为可见密码),但这种方法是不是很好,我仍然在寻找更好的。

I solved this by disabling autocomplete feature (it will be disabled if you'll set the edit type to Visible Password), but this solution is not very good and I'm still in search for better one.

private SearchView getSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
    searchView.setQueryHint("Search for items");
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    AutoCompleteTextView searchTextView =
            (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
    if (searchTextView != null) {
        searchTextView.setInputType(InputType.TYPE_CLASS_TEXT
                                    | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
        searchTextView.setTypeface(Typeface.DEFAULT);
    }
    return searchView;
}

这篇关于如何改变自动完成文本颜色搜索查看ActionBarSherlock内与黑暗的背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆