问题
I have implemented contextual action mode on long press inside recycler view
. For that i have called ActionModeCallback
from creating action mode .
While creating action mode , back arrow is showing by default . Check below :
On click back arrow , action mode will close.
Now i want to hide
or remove
that default back button which is coming along with action mode
in android .
Note : Already tried getActionBar().setDisplayHomeAsUpEnabled(false).
but it's not working . Kindly help.
Edited :
Thanks Issues been resolved : After adding in style.xml
<item name="actionModeCloseDrawable">@color/colorPrimary</item>
<item name="actionModeCloseButtonStyle">@style/Widget.AppCompat.ActionMode</item>
回答1:
Try this to completely remove it:
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
}
Update
or try to 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"
...
/>
回答2:
Add below the item 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>
来源:https://stackoverflow.com/questions/38138881/remove-back-home-button-from-action-mode-on-long-press-in-android