Remove back / home button from action mode on long press in android

I used contextual action mode on long press inside recycler view

. For this I have called ActionModeCallback

from the action mode creation.

When creating an action mode, a back arrow is displayed by default. Check below:

enter image description here

Clicking on the arrow will close the action.

Now I want hide

either remove

this default back button that comes with action mode

in android.

Note. Already tried getActionBar().setDisplayHomeAsUpEnabled(false).

it but it doesn't work. Please help.

Edited:

Thank. Issues resolved: After adding to style.xml

<item name="actionModeCloseDrawable">@color/colorPrimary</item>
    <item name="actionModeCloseButtonStyle">@style/Widget.AppCompat.ActionMode</item>

      

+1


source to share


2 answers


Try to remove it completely:

ActionBar actionBar = getActionBar();
if (actionBar != null) {
    actionBar.setHomeButtonEnabled(false);      
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false); 
}

      

Update

or try using a custom theme



<style name="yourTheme" parent="theThemeYouUse">
    <item name="android:actionModeCloseDrawable">@drawable/yourBack</item>
</style>

      

and in the manifest:

<activity
        android:name="yourActivity"
        android:theme="@style/yourTheme"
  ...
/>

      

+1


source


Add below paragraph to your style



 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
     ...
        <item name="actionModeCloseButtonStyle">@style/NoCloseButtonActionModeStyle</item>
    </style>
<style name="NoCloseButtonActionModeStyle">
        <item name="android:visibility">gone</item>
    </style>

      

0


source







All Articles