Android-Iconics icon indicating copy to clipboard operation
Android-Iconics copied to clipboard

Icons size is not correct

Open leelei opened this issue 11 years ago • 7 comments

compile 'com.mikepenz:iconics:1.2.1@aar'
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.menu_main);
    toolbar.setNavigationIcon(
        new IconicsDrawable(this, GoogleMaterial.Icon.gmd_arrow_back).actionBar());
    toolbar.getMenu()
        .findItem(R.id.action_share)
        .setIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_arrow_back).actionBar());
    toolbar.getMenu()
        .findItem(R.id.action_comment)
        .setIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_comment).actionBar());

icons size not the standard Material Design

if i use

compile 'com.mikepenz.iconics:library:0.7.5@aar'
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.menu_main);
    toolbar.setNavigationIcon(
        new IconicsDrawableOld(this, GoogleMaterial.Icon.gmd_arrow_back).actionBarSize());
    toolbar.getMenu()
        .findItem(R.id.action_share)
        .setIcon(new IconicsDrawableOld(this, GoogleMaterial.Icon.gmd_arrow_back).actionBarSize());
    toolbar.getMenu()
        .findItem(R.id.action_comment)
        .setIcon(new IconicsDrawableOld(this, GoogleMaterial.Icon.gmd_comment).actionBarSize());

this is the correct size

leelei avatar Jul 13 '15 09:07 leelei

The size with the newest lib is 24dp for the icon and 6dp padding.

    public static final int ANDROID_ACTIONBAR_ICON_SIZE_DP = 24;
    public static final int ANDROID_ACTIONBAR_ICON_SIZE_PADDING_DP = 6;
public IconicsDrawable actionBar() {
        sizeDp(ANDROID_ACTIONBAR_ICON_SIZE_DP + (2 * ANDROID_ACTIONBAR_ICON_SIZE_PADDING_DP));
        paddingDp(ANDROID_ACTIONBAR_ICON_SIZE_PADDING_DP);
        return this;
}

mikepenz avatar Jul 13 '15 10:07 mikepenz

As of this screenshot in the Material Design Guidelines the Icon should be the size of 24dp

  • 56dp actionBarSize
  • 16dp padding layout_structure_appbar_metrics1

So it should be fine. if a specific icon needs more padding you can define the size manually

mikepenz avatar Jul 13 '15 10:07 mikepenz

@leelei have you tested on Android M?

mikepenz avatar Jul 15 '15 22:07 mikepenz

On Android 4.4.4, the 6dp padding makes the icons slightly large. If I try to set .paddingDp(int) manually it seems to add that arg to the padding already defined. So, if I set .paddingDp(8) it makes the icon extremely small. However, setting to .paddingDp(2) seems to simply add it to the existing 6dp padding that you have thus making it the correct size.

I think it might be more intuitive to override the padding with the argument instead of adding to it.

rf3Studios avatar Jul 17 '15 22:07 rf3Studios

@rf3Studios i have modified this behavior on the latest version. the icon is now 24dp with 1dp padding

mikepenz avatar Jul 18 '15 16:07 mikepenz

I wanted to replace icons in Toolbar from resources to IconicsDrawable. I had icons defined as:

android:icon="@drawable/ic_refresh_white_24dp"

with "ic_refresh_white_24dp.png" from official repository and it looks like this:

iconics_size1

Then I replaced refresh icon with IconicsDrawable

IconicsDrawable layersIcon = new IconicsDrawable(context, GoogleMaterial.Icon.gmd_refresh);
menu.findItem(menuItemId).setIcon(layersIcon.actionBar());

And icon was bigger:

iconics_size2

I had to set different size and padding for expected size according to Material guidelines:

IconicsDrawable layersIcon = new IconicsDrawable(context, GoogleMaterial.Icon.gmd_refresh);
layersIcon = layersIcon.sizeDp(24);
layersIcon = layersIcon.paddingDp(4);
menu.findItem(menuItemId).setIcon(layersIcon);

iconics_size3

I've tried on 5.0.0 and 5.1.1 with 1080x1920, 480dpi

Is this behavior of actionBar method correct?

novalu avatar Sep 20 '15 10:09 novalu

@novalu the actionBar method is correct as far as possible for the lib. The thing is that google does not use the same paddings for all of their icons, and i see no programmatically solution to automatically define the different paddings.

The actionBar method sets the size to 24dp with 1dp padding by default. In some cases this will be different as you found out already

mikepenz avatar Sep 20 '15 10:09 mikepenz