简体   繁体   中英

Image as an Icon for NavigationView Item

I'm looking to use a full color image as the icon for a menu item in a NavigationView. The image would need to be larger than the standard icons, and not have a color tint. (Like a profile image) I've found ways to both change the icon size but not on specific items. It looks like you have to change a global, private attribute for that to work. Is using a app:actionLayout that defines the entire item my only option?

这是截图

from Google's Calendar app which shows exactly what I'm looking for.

Without creating a custom drawer, the only way is adding a header layout (app:headerLayout):

<com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer"/>

If you want a more customizable nav drawer, I recommend this one: https://github.com/mikepenz/MaterialDrawer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM