【问题标题】:Sherlock action bar change text colorSherlock 操作栏更改文本颜色
【发布时间】:2012-07-31 08:09:41
【问题描述】:

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

我有这个主题

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

【问题讨论】:

    标签: android actionbarsherlock


    【解决方案1】:

    实际上,我已经通过执行以下操作在 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>
    

    【讨论】:

      【解决方案2】:

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

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

      到 Sherlock 操作栏主题?

      然后在你的 values/color.xml 你有颜色:

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

      【讨论】:

        【解决方案3】:

        感谢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);
        ...
        

        【讨论】:

          【解决方案4】:

          用这个就对了。 :D

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

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-12-13
            相关资源
            最近更新 更多