An open API service indexing awesome lists of open source software.

https://github.com/outadoc/mdi-android

Android library that provides the latest Material Design Icons (@templarian/MaterialDesign)
https://github.com/outadoc/mdi-android

Last synced: 9 months ago
JSON representation

Android library that provides the latest Material Design Icons (@templarian/MaterialDesign)

Awesome Lists containing this project

README

          

# mdi-android
This library provides an Android wrapper around the [Material Design Icons](https://materialdesignicons.com/)
icon library, for convenient use in Android applications.

THE ICONS WRAPPED BY THIS LIBRARY ARE PROVIDED AS-IS AND COPYRIGHTED TO A THIRD-PARTY. Please see the
License section for details.

## Setup
This library is hosted on Github Packages. In your projec's root `build.gradle.kts` file, add the Github Packages repository:

```kt
allprojects {
repositories {
google()
mavenCentral()

// [...]

maven(url = "https://maven.pkg.github.com/outadoc/mdi-android") {
credentials {
username = "token"
password = "TOKEN-WITH-READ-PACKAGES-ROLE-HERE"
}
}
}
}
```

You will need to [generate a Github Access Token](https://github.com/settings/tokens/new). Give it the `read:packages` scope.

In your module's `build.gradle.kts`, add the dependency:

```kt
dependencies {
// [...]
implementation("fr.outadoc.mdi:mdi-android:+")
}
```

## Usage
You can use a custom view to display your icons:

```xml

```

You can also use a standard appcompat `TextView`. You just have to set the `TextAppearance.MaterialDesignIcons`
text appearance on it.

```xml

```

In code, setup the library and convert the icon's reference into the right object.

```kt
// Create an instance of the Android icon mapper with a Context,
// and set it on the MdiMapperLocator. Do this in your Application class or similar.
MdiMapperLocator.instance = AndroidMdiMapper(applicationContext)

// Convert an icon's reference to a proper font icon instance
val icon1: MdiFontIcon = "toaster-oven".toIcon()
val icon2: MdiFontIcon? = "toaster-oven".toIconOrNull()

// Set the icon on the TextView
textView_fontIcon_example.setText(icon1.unicodePoint)

// Or using the ktx
textView_fontIcon_example.setIcon(icon1)
```

## Sample application
You will find a sample application [in this repo](sample/) that uses the library to display all available icons.

| | |
|---|---|
| ![Screenshot 1](assets/sample-screenshot0.png) | ![Screenshot 2](assets/sample-screenshot1.png) |

## License
The icons provided by this library are made and maintained by the [Pictogrammers](http://pictogrammers.com/)
icon group. See more at @templarian/MaterialDesign.

The source code of this repository is available under the Apache 2.0 License.