I would like to know how do I change the color of the selected items, ActionBar?

-2

<!--styles.xml--><resources><!--Basedotemadaaplicação.--><stylename="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    </style>

     <!-- Cor do Menu -->
    <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">true</item>
        <item name="color">@android:color/white</item>
    </style>

</resources>
<?xml version="1.0" encoding="utf-8"?>


<!-- color.xml -->    


<resources>

    <!--cor principal do aplicativo-->
    <color name="colorPrimary">#93662f</color>
    <color name="colorPrimaryDark">#3a1a0b</color>
    <color name="colorAccent">#93662f</color>

    <!--deslize para baixo atualizar a cor da animação-->
    <color name="orange">#FF9900</color>
    <color name="green">#009900</color>
    <color name="blue">#000099</color>
    <color name="red">#ff0015</color>

    <!--outra cor-->
    <color name="background_color">#e2e2e2</color>
    <color name="divider">#f2f2f2</color>
    <color name="text_color">#525252</color>
    <color name="white">#ffffff</color>

</resources>
    
asked by anonymous 21.12.2017 / 23:04

1 answer

0

You can change the color of a View when pressed (for example: textView, button etc) by creating Selectors:

drawable / selector.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/custom_color"/>
    <corners android:radius="8dp"/>
</shape>

color / custom_color.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android
    <item android:color="@color/blue_bt_pressed" android:state_pressed="true" />
    <item android:color="@color/blue_bt"/>
</selector>

And in your View add:

android:background ="@drawable/selector

I do not know how you can implement this in ActionBar but I hope this can help.

    
22.12.2017 / 00:14