If you're tired of copying 5 images (ldpi, mdpi, hdpi, xhdpi, xxhdpi) for each icon you want to use in your app, for each color you want to use them with, and bang your head on the wall when you suddenly need to change their color or size, then I think Iconify
can help you.
Iconify allows you to easily include vector icons in your TextView
, Button
, etc…
The icons are infinitely scalable, and customizable with shadows and everything you can do on texts.
It currently supports a few icon font libraries out-of-the-box, and there are many more to come. In case you need a custom one, it allows you to add your own icons from icon font generation services like fontello.com, icomoon.io or fontastic.me.
If you're migrating from version 1.X.X, please read the migration guide.
Choose the modules you want using the demo app.
Declare them in your build.gradle
and in your Application
.
dependencies {
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.0.4'
compile 'com.joanzapata.iconify:android-iconify-entypo:2.0.4'
compile 'com.joanzapata.iconify:android-iconify-typicons:2.0.4'
compile 'com.joanzapata.iconify:android-iconify-material:2.0.4'
compile 'com.joanzapata.iconify:android-iconify-meteocons:2.0.4'
compile 'com.joanzapata.iconify:android-iconify-weathericons:2.0.4'
compile 'com.joanzapata.iconify:android-iconify-simplelineicons:2.0.4'
}
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Iconify
.with(new FontAwesomeModule())
.with(new EntypoModule())
.with(new TypiconsModule());
.with(new MaterialModule());
.with(new MeteoconsModule());
.with(new WeathericonsModule());
.with(new SimpleLineIconsModule());
}
}
If you need to put an icon on a TextView
or a Button
, use the { }
syntax. The icons act exactly like the text, so you can apply shadow, size and color on them!
<com.joanzapata.iconify.widget.IconTextView
android:text="I {fa-heart-o} to {fa-code} on {fa-android}"
android:shadowColor="#22000000"
android:shadowDx="3"
android:shadowDy="3"
android:shadowRadius="1"
android:textSize="40sp"
android:textColor="#FF..."
... />
You can either use
IconTextView
/IconButton
or use anyTextView
and then programmatically callIconify.addIcons(myTextView)
.
Shall you need to override the text size of a particular icon, the following syntax is supported
{fa-code 12px}
,{fa-code 12dp}
,{fa-code 12sp}
,{fa-code @dimen/my_text_size}
, and also{fa-code 120%}
. In the same way you can override the icon color using{fa-code #RRGGBB}
,{fa-code #AARRGGBB}
, or{fa-code @color/my_color}
.
If you need an icon in an ImageView
or in your ActionBar
menu item, then you should use IconDrawable
. Again, icons are infinitely scalable and will never get fuzzy!
// Set an icon in the ActionBar
menu.findItem(R.id.share).setIcon(
new IconDrawable(this, FontAwesomeIcons.fa_share)
.colorRes(R.color.ab_icon)
.actionBarSize());
If you use Proguard, don't forget to add the following rule.
-keep class com.joanzapata.** { *; }
- Joan Zapata @JoanZapata
- Damien Villeneuve @DayS
- Mike Penz @mikepenz
Copyright 2015 Joan Zapata
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
It uses FontAwesome font by Dave Gandy, licensed under OFL 1.1, which is compatible
with this library's license.
http://scripts.sil.org/cms/scripts/render_download.php?format=file&media_id=OFL_plaintext&filename=OFL.txt