Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

material-icon-lib

> 编程语言
Open source

Library containing over 2000 material vector icons that can be easily used as Drawable or as a standalone View.

2.3K stars0 likes0 views
WebsiteGitHub

About

Library containing over 2000 material vector icons that can be easily used as Drawable or as a standalone View.

Material Icon Library

A library containing over 2000 material vector icons that can be easily used as Drawable, a standalone View or inside menu resource files. Tired of having to search for and generate png resources every time you want to test something? This library puts an end to that burden and makes swapping icons a breeze, check out the usage below and you'll see why.

Demo

Stats

  • MinSdk 4
  • LIVE previews and code completion in the Android Studio Designer (Does NOT work out of the box, see step 0 below!)
  • Currently contains 2354 icons, you can look at them here: https://materialdesignicons.com
  • Configured in less than a minute
  • Adds about 257kb to your apk (so a whopping average of 109 bytes per icon)
  • Includes a custom Drawable, IconView and a MenuInflater for all different icon use cases

Usage

Step 0

Now I still have your attention, to get the previews to work in Android Studio you'll have to put the font file inside the assets of your project yourself. Due to a bug it does not think about looking inside the library's assets for some odd reason.

Get the font file here.

You don't have to worry about android including the file twice in your apk. Android Studio recognizes the duplicate file name and only keeps one copy in your apk!

Previews work inside layout files, menu resource files sadly do not support previews (more on those below).

Step 1

Gradle

dependencies {
    compile 'net.steamcrafted:materialiconlib:1.1.5'
}

Step 2

There's a total of 3 different use cases (click the links to jump to their section). You can use the provided MaterialIconView which mostly is just a more advanced ImageView or use your preferred ImageView and use the MaterialDrawable as Drawable resource. If you want to spice up your Toolbar with icons from this library there is a custom MaterialMenuInflater that does just that in a single line of code.

MaterialIconView

Add the view to your XML:

<net.steamcrafted.materialiconlib.MaterialIconView
    xmlns:app="http://schemas.android.com/apk/res-auto" 

    android:layout_width="48dp"
    android:layout_height="48dp"
    app:materialIcon="clipboard_arrow_down" 
    app:materialIconColor="#fff" 
    app:materialIconSize="24dp"  
    android:scaleType="center" 
    android:background="@android:color/darker_gray"
    android:id="@+id/icon"
/>

You can also use the other route: the "wrap_content" way:

<net.steamcrafted.materialiconlib.MaterialIconView
    xmlns:app="http://schemas.android.com/apk/res-auto" 

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="12dp" 
    app:materialIcon="clipboard_arrow_down" 
    app:materialIconColor="#fff" 
    app:materialIconSize="24dp"  
    
    android:background="@android:color/darker_gray"
    android:id="@+id/icon"
/>

The view is inherited from ImageView. This means that you can use any and all features of the very flexible ImageView BUT be reminded that this view does not cache any of the drawables it creates, so every time you change something about the icon, it's going to regenerate the drawable. Using this view inside listviews is highly discouraged, if you want to use these icons in a ListView, cache the drawables and use the MaterialDrawableBuilder in combination with an ImageView!

As mentioned before this extends the android ImageView class, there's a few methods unique to this particular view:

…

MaterialDrawable

That was easy, right? Next up the custom drawables, they are internally used by the MaterialIconView so you'll see that they share many of the same methods.

The initialisation happens using the MaterialDrawableBuilder, which you can use to set all the properties of the drawable:

// The method returns a MaterialDrawable, but as it is private to the builder you'll have to store it as a regular Drawable ;)
Drawable yourDrawable = MaterialDrawableBuilder.with(context) // provide a context
        .setIcon(MaterialDrawableBuilder.IconValue.WEATHER_RAINY) // provide an icon
        .setColor(Color.WHITE) // set the icon color
        .setToActionbarSize() // set the icon size
    .build(); // Finally call build

This will throw an IconNotSetException if you forget to provide an icon.

Once you call build, your Drawable will be spit out and you are ready to use it everywhere you please! Setting it to a view is just as easy as with any other Drawable (e.g. for ImageView):

yourImageView.setImageDrawable(yourDrawable);

And that's all there is to it. Below are all the methods you can use with the MaterialDrawableBuilder for reference.

…

MaterialMenuInflater

With the MaterialMenuInflater you can use any of the icons available in this library inside your menu resource files. In XML you'd have to do the following:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" >

    
    <item
        android:title="Disable Wifi"
        app:showAsAction="always"
        app:materialIcon="wifi_off" 
        app:materialIconColor="#FE0000" 
    />

</menu>

To actually inflate this menu you'll now have to use the MaterialMenuInflater instead of the default one. For the AppCompatActivity do the following in your onCreateOptionsMenu:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MaterialMenuInflater
            .with(this) // Provide the activity context
            // Set the fall-back color for all the icons. Colors set inside the XML will always have higher priority
            .setDefaultColor(Color.BLUE)
            // Inflate the menu
            .inflate(R.menu.your_menu_resource, menu);
    return true;
}

Since the release of the Appcompat-v7 library you can also use the Toolbar view inside your XML layouts. Inflating a menu for a toolbar is a bit different from the usual way, but it is just as easy:

// Get the toolbar from layout
Toolbar toolbar = (Toolbar) findViewById(R.id.your_toolbar);

MaterialMenuInflater
        .with(this) // Provide a context, activity context will do just fine
        // Set the fall-back color for all the icons. Colors set inside the XML will always have higher priority
        .setDefaultColor(Color.BLUE)
        // Inflate the menu
        .inflate(R.menu.your_menu_resource, toolbar.getMenu());

And that's all there is to it.

License

Released under the Apache 2.0 License

  • MaterialDesignicons Released under the SIL Open Font License 1.1
  • Google Material Design Icons Released under the Apache 2.0 License

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言