/MdiDrawable

Material Design Icon drawable run time generator

Primary LanguageHTMLMIT LicenseMIT

GitHub license

MdiDrawable

This library is a simple Material Design Icon icon generator. Just simply provide the icon name resource id, and the library will generate the icon drawable for you at run time. You don't need to download each png file from website everytime.

Gradle:

allprojects {
    repositories {
      ...
      maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.kevinchung0921:MdiDrawable:0.1.3'
}

Basic usage:

Use the following code when you need an alert icon programmaticaly

imageview.background = MdiDrawableConfig()
     .stringId(R.string.mdi_alert_decagram)
     .create(context)

Or use MdiView class to create it in layout file.

<com.kevinchung.mdi_drawable.MdiView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/mdi_calendar"
            android:textSize="40dp"
            android:padding="4dp"
            app:bgColor = "@color/blue_grey_600"
            app:useGradient="true"
            app:cornerRadius="6dp"
            app:gradientStartColor="@color/blue_grey_600"
            app:gradientEndColor="@color/blue_grey_100"
            app:gradientOrientation="rightLeft"
            app:strokeWidth="1dp"
            app:strokeColor="@color/black"
            />

And put the drawable into an ImageView or to the any view which support background drawable.

The icon string resource name could found in and add prefix "mdi_" and change dash "-" to underscope "_"

More settings:

imageview.background = MdiDrawableConfig()
    .stringId(R.string.mdi_android)
    .size(60)
    .radius(60)
    .iconColor(Color.BLUE)
    .enableBackground(true)
    .useGradient(Color.DKGRAY, Color.LTGRAY)
    .stroke(width=2, color.BLACK, length=10, gap=2)
    .shadow(color=Color.BLACK, radius=4, dx=10, dy=10)
    .create(context)

Demo:

This project also come with a demo app which show different drawable configurations.

And also provide a dialog allow you to create drawable at runtime.

Update Library:

If you need to use latest icon whenever Material Font updated, just delete the folder "mdi" under the library project folder and execute "donwload.py". This will download the latest Material Design Font package and generate string resource table.