Android的支持工具栏colorControlNormal颜色工具栏、颜色、Android、colorControlNormal

由网友(你是风景也是陷阱)分享简介:我想设置我的微调下拉颜色为白色,同时保持其他元素在我的主题默认的颜色。这里的情况是:I would like to set my spinner drop down color to white, whilst keeping the other elements in my theme the default co...

我想设置我的微调下拉颜色为白色,同时保持其他元素在我的主题默认的颜色。这里的情况是:

I would like to set my spinner drop down color to white, whilst keeping the other elements in my theme the default color. Here is the situation:

<android.support.v7.widget.Toolbar
        android:layout_height="@dimen/action_bar_height"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:theme="@style/ToolbarTheme.Base"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        <Spinner
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"/>

</android.support.v7.widget.Toolbar>

和的风格是:

<!-- My base app theme -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/theme_tint</item>

    <!-- <item name="colorControlNormal">#FFFFFF</item> -->

    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:typeface">sans</item>
    <item name="android:windowBackground">@color/background_primary</item>
</style>

<!-- My Toolbar theme -->
<style name="ToolbarTheme.Base" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="colorControlNormal">#FFFFFF</item>
</style>

如果我把&LT;项目名称=colorControlNormal&GT;#FFFFFF&LT; /项目&GT; 在App主题(上面注释),那么微调降下来会做白色,但该复选框也会变成白色。所以,我怎么能得到微调只有走白?

If I was to put <item name="colorControlNormal">#FFFFFF</item> in the App theme (commented out above) then the spinner drop down will do to white BUT the checkbox will also turn white. So how can I get the spinner ONLY to go white?

推荐答案

最后,我已经找到了如何更改微调的箭头颜色为白色的解决方案。

Finally, I have found a solution on how to change arrow color of Spinner to white.

1)在 styles.xml ,添加以下样式:

1) In styles.xml, add the following style:

<style name="ActionBarThemeOverlay" parent="">
    <item name="android:textColorPrimary">#ffffff</item>
    <item name="colorControlNormal">#ffffff</item>
    <item name="colorControlHighlight">#ff33b5e5</item>
</style>

<style name="Widget.MyTheme.HeaderBar.Spinner" parent="Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
    <item name="android:theme">@style/ActionBarThemeOverlay</item>
</style>

2)在布局,在那里你使用微调(在你的情况与工具栏),添加风格的微调:

2) In the layout, where you use the Spinner (in your case with Toolbar), add the style to your spinner:

<Spinner
    xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/my_spinner"
         style="@style/Widget.MyTheme.HeaderBar.Spinner"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" />
阅读全文

相关推荐

最新文章