Search code examples
androidbackgroundandroid-actionbaractionandroid-actionmode

Android action mode view background color is not able to change


Hi this is my style attributes, "myAppTheme" is my application's theme and "MyActionModeStyle" is my actionmode's style.

      <style name="myAppTheme" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/primaryColor</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="android:windowActionModeOverlay">true</item>
        <item name="actionModeStyle">@style/MyActionModeStyle</item>
    </style>

    <style name="MyActionModeStyle" parent="Widget.AppCompat.ActionMode">
        <item name="actionModeBackground">@drawable/red_bg</item>
        <item name="android:actionModeBackground">@drawable/red_bg</item>
        <item name="backgroundSplit">@drawable/red_bg</item>
        <item name="android:backgroundSplit">@drawable/red_bg</item>
        <item name="android:titleTextStyle">@style/ActionModeText</item>
        <item name="titleTextStyle">@style/ActionModeText</item>
    </style>

I want to change the background of action ode to red color but unfortunately nothing happends, still action mode is in default white color.. How can i change its color.. Any idea ?

Solution

  • Oh ! At last i had got a solution.I had changed my action mode custom theme into activities' theme.Now its works.. This is my custom theme for activity

    android:theme="@style/customActionModeTheme" 
    

    and this is my custom style

    <style name="customActionModeTheme" parent="myAppTheme"> 
        <item name="android:actionModeBackground">@color/primaryColor</item> 
        <item name="actionModeBackground">@color/primaryColor</item> 
    </style>