如何在NavigationView中更改菜单项图标的大小?

问题描述:

我有以下菜单项:

<item
        android:id="@+id/lock"
        android:checkable="true"
        android:title="@string/lock" >
    <menu >

        <item
            android:id="@+id/block_mess"
            android:checked="true"
            android:icon="@drawable/chantinnhan"
            android:title="@string/block_mess_string" />

        <item
            android:id="@+id/block_call"
            android:checked="false"
            android:icon="@drawable/chancuocgoi"
            android:title="@string/block_call_string" />

        <item
            android:id="@+id/lock_app"
            android:checked="false"
            android:icon="@drawable/khoaungdung"
            android:title="@string/lock_app_string" />


    </menu>
    </item>

...还有更多,但确实很长

...there's still more but it's really long

,但图标确实很小(即使它的分辨率为256x256).我想把它做大!那可能吗? 这是屏幕截图:

but the icon is really small (even it has res 256x256). I'd like to make it bigger! Is that possible? Here's the screenshot:

好的,我们俩都知道Google锁定"了图标的大小.但是我想知道我可以绕过"那个锁并做一些可定制的事情吗?

OK, we both know that Google "lock" the icon size. But I want to know that can I "bypass" that lock and make something... customizable ?

您可以通过覆盖design_navigation_icon_size属性来更改navigationView图标的大小.您可以将其放为变暗,并且由于您要覆盖私有属性,因此需要包含tools:override="true"

You can change the size of navigationView icon by overriding design_navigation_icon_size attribute. You can put it in dimens and because you're overriding a private attribute, you need to include tools:override="true"

<dimen name="design_navigation_icon_size" tools:override="true">40dp</dimen>