how to Customize the Contextual Action Bar using appCompat in material design

前端 未结 3 863
醉话见心
醉话见心 2020-11-29 22:50

MainActivity.java

I\'ve implemented MultiChoiceModeListener in this class and below is the code:

on listView:

相关标签:
3条回答
  • 2020-11-29 23:27

    You can change the ActionMode background through attribute actionModeStyle:

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light">
        ....
        ....
        <item name="actionModeStyle">@style/LStyled.ActionMode</item>
    </style>
    
    <style name="LStyled.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
        <item name="background">@color/color_action_mode_bg</item>
    </style>
    

    You will of course need to define a color named color_action_mode_bg:

    <color name="color_action_mode_bg">#009688</color>
    

    There are other things you can change as well. Example:

    <item name="titleTextStyle">...</item>
    <item name="subtitleTextStyle">...</item>
    <item name="height">...</item>
    

    To change text color of SAVE and SAVETO, add the following to AppTheme.Base:

    <item name="actionMenuTextColor">@color/color_action_mode_text</item>
    
    0 讨论(0)
  • 2020-11-29 23:48

    To change the Title Color of contextual action bar this was the only method that worked for me:

    Write this in your activity's theme

    <item name="actionModeStyle">@style/ContextualActionModeTheme</item>
    

    Define the styles

    <style name="ContextualActionModeTheme" parent="@style/Widget.AppCompat.ActionMode">
           <item name="titleTextStyle">@style/titleColor</item>
    </style>
    <style name="titleColor" parent="TextAppearance.AppCompat.Widget.ActionMode.Title">
           <item name="android:textColor">@color/your_color_here</item>
    </style>
    

    The title color of your contextual action bar would be changed.

    0 讨论(0)
  • 2020-11-29 23:50

    use actionModeBackground in your AppTheme.Base style.

    <item name="actionModeBackground">@color/colorPrimary </item> (or)
    <item name="android:actionModeBackground">@color/colorPrimary </item>
    
    0 讨论(0)
提交回复
热议问题