Material Design icon colors

前端 未结 3 668
眼角桃花
眼角桃花 2021-02-01 14:56

Which color should be the \"dark\" material icon?

On the official documentation (https://www.google.com/design/spec/style/icons.html#icons-system-icons

3条回答
  •  后悔当初
    2021-02-01 15:09

    There are three ways I handle opacity:

    a) Simple one, I download them (on materialdesignicons.com if I need the grey option) and use them, as I don't need to change anything in any way. If I don't find the one I need, I download the black (white) one and transform it into the 54% opacity version of it (it's a 30 seconds job on gimp/photoshop).

    b) If I only need the "normal" and "pressed" state, I download the black (white) one, create the two versions, at 54% for natural and 87% for pressed, then I create a drawable file to combine them (you can handle focused too):

    
    
             
             
             
    
    

    c) If I need to change the opacity of the icon often in my code, I do it progammatically:

    ImageButton mButton = (ImageButton) findViewById(R.id.button);
    final Drawable buttonIcon = context.getResources().getDrawable(R.mipmap.your_icon);
    buttonIcon.setAlpha(138); //this is the value of opacity 1~255
    mButton.setBackground(buttonIcon);
    

    Note that you can combine the methods b) and c), so you don't have to control the pressing change of opacity programmatically, but still be able to change its overall value as you need.

提交回复
热议问题