Change Popup menu background color

后端 未结 10 1461
执念已碎
执念已碎 2020-12-05 11:28

NOTE: I have searched for an hour and tried all solutions already provided by stackoverflow.

I am studying theme over

10条回答
  •  感动是毒
    2020-12-05 12:18

    i did it pls check if anybody have problem too add this to style

     
    
    
    

    and the code of popmenu is

     private void openPopMenuList(View view) {
        //custom background COlor view
        PopupMenu popup = new PopupMenu(new ContextThemeWrapper(getActivity(), R.style.CustomPopupTheme), view);
        try {
            // Reflection apis to enforce show icon
            Field[] fields = popup.getClass().getDeclaredFields();
            for (Field field : fields) {
                if (field.getName().equals( POPUP_CONSTANT )) {
                    field.setAccessible( true );
                    Object menuPopupHelper = field.get( popup );
                    Class classPopupHelper = Class.forName( menuPopupHelper.getClass().getName() );
                    Method setForceIcons = classPopupHelper.getMethod( POPUP_FORCE_SHOW_ICON, boolean.class );
                    setForceIcons.invoke( menuPopupHelper, true );
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        popup.getMenuInflater().inflate( R.menu.pop_up_menu, popup.getMenu() );
        popup.setOnMenuItemClickListener( this );
        popup.show();
    
    
    }
    

    and the below is popmenu items

    
    

    
    
    
    
    

提交回复
热议问题