Android 12 | ActionMode menu items are not showing icons but only title in Contextual Action Mode, type_floating

169 Views Asked by At

I am using Action mode type_floating in webview where am showing action mode on long click of webview. It is showing action mode menu items correctly but in Android 12, it is just showing titlte names instead of icon. This is my onActionModeStarted method:

 @Override
public void onActionModeStarted(ActionMode mode) {
    Menu menu = mode.getMenu();
    menu.clear();
    mode.getMenuInflater().inflate(R.menu.menu_feature,menu);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        mode.invalidateContentRect();
    }
    setFloatingMenuClickListeners(menu);
    super.onActionModeStarted(mode);
}

private void setFloatingMenuClickListeners(Menu menu) {

    MenuItem red = menu.findItem(R.id.red_view).setOnMenuItemClickListener(actionModeClick);
    note.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    note.setIcon(R.drawable.icon_name);
   
    MenuItem orange = menu.findItem(R.id.orange_view).setOnMenuItemClickListener(actionModeClick);

    MenuItem pink = menu.findItem(R.id.pink_view).setOnMenuItemClickListener(actionModeClick);
    }

enter image description here

In devices, below Android 12, it is showing only icons which is required. But in Android 12,showing only title.

0

There are 0 best solutions below