There isn't any toolbar but showing contextual action bar when text selection below api v23, following codes not working to disable/remove. How to disable/remove completely?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_read_book);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
if (getSupportActionBar() != null) {
getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(false);
getSupportActionBar().setDisplayShowCustomEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().removeAllTabs();
getSupportActionBar().setShowHideAnimationEnabled(false);
getSupportActionBar().hide();
getSupportActionBar().collapseActionView();
getSupportActionBar().closeOptionsMenu();
getSupportActionBar().setHomeAsUpIndicator(null);
}
}
My App Theme:
<style name="MyAppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
...
<item name="windowActionBar">false</item>
...
</style>
Edit:
Opening a special menu fragmen when long clicked my TextView with CustomSelectionActionModeCallback, and I've to return true the onCreateActionMode method because of to avoid selection cancellation during the selection, in this way (returning true) the event is prevented from going down but the action bar is opening api level 23 and down.
mTextViewItem.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
...
showMyMenuFragment();
...
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
menu.clear();
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
