Giter VIP home page Giter VIP logo

android-iconify's Introduction

Note: Due to lack of time, Iconify is no longer maintained and icon packs are outdated. I'd be very happy to welcome a new contributor, please reach me on twitter @JoanZap if by any chance you're interested. 🙂

Iconify offers you a huge collection of vector icons to choose from, and an intuitive way to add and customize them in your Android app. It has been introduced in this blog post which is a good place to get started.


Install

Pick any number of modules and declare them in your Application.

dependencies {
    compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2' // (v4.5)
    compile 'com.joanzapata.iconify:android-iconify-entypo:2.2.2' // (v3,2015)
    compile 'com.joanzapata.iconify:android-iconify-typicons:2.2.2' // (v2.0.7)
    compile 'com.joanzapata.iconify:android-iconify-material:2.2.2' // (v2.0.0)
    compile 'com.joanzapata.iconify:android-iconify-material-community:2.2.2' // (v1.4.57)
    compile 'com.joanzapata.iconify:android-iconify-meteocons:2.2.2' // (latest)
    compile 'com.joanzapata.iconify:android-iconify-weathericons:2.2.2' // (v2.0)
    compile 'com.joanzapata.iconify:android-iconify-simplelineicons:2.2.2' // (v1.0.0)
    compile 'com.joanzapata.iconify:android-iconify-ionicons:2.2.2' // (v2.0.1)
}
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 MaterialCommunityModule())
            .with(new MeteoconsModule())
            .with(new WeathericonsModule())
            .with(new SimpleLineIconsModule())
            .with(new IoniconsModule());
    }
}

Show icons in text widgets

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..."
    ... />

Icon options

  • 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}.
  • You can even easily spin an icon like so {fa-cog spin}.

Show an icon where you need a Drawable

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());

Extensibility

In case you can't find the icon you want, you can extend the available icon directly from your app. All you need to do is to implement IconFontDescriptor with a .ttf file in your assets and provide the mapping between keys and special characters, then give it to Iconify.with(). You can use the FontAwesomeModule as an example.

There are no constraints on the icon keys, but I strongly suggest you use a unique prefix like my- or anything, to avoid conflicts with other modules. FYI, if there is a conflict, the first module declared with Iconify.with() has priority.

The only dependency you need if you want to use a custom icon is Iconify core.

compile 'com.joanzapata.iconify:android-iconify:2.2.2'

Contributions

License

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
    

android-iconify's People

Contributors

1zaman avatar days avatar devnied avatar joanzapata avatar john990 avatar lccxx avatar makubi avatar mikepenz avatar msneujink avatar synapticvoid avatar tasomaniac avatar weiyin avatar william-lohan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-iconify's Issues

Make icon size and color independent of the text

Expand the {icon_**} pattern to encapsulate more info like

{icon_thumbs_up #99 0.8f} for a blue small icon
or
{icon_twitter #999999} for a gray normal sized icon
or
{icon_globe #990000 5.0f} for a red large icon

I have implemented this (check the forked repo) but still need to figure out how we can

  • make center_vertical work (text is now always in bottom)
  • make it work with IconTextView ( now only works with addIcons() or setText() )

Maybe you want to take a look at it? =D
Thanks for the nice project, really like your approach on embedding the icon in the text.

Set font size of icon different from text

I use the IconButton to display a button with text and an icon. Works well, but font-awesome tends to be a little smaller than the actual text. Therefore it would be nice to change the size of the icon only.
Something like

<android.widget.IconButton
            android:text="{fa-icon} text"
            android:textSize="22sp"
            android:iconSize="30sp"
... />

String Resource File

I've created a string resource file that can be included in your android project to make the icon values easy to reference reference. I know you can use the enum within the library, but I needed an easy way to be able to alias the icon names.

https://gist.github.com/keannan5390/9487918

Then you can use it like this:

TextView icon = (TextView)findViewById(R.id.icon_name);
icon.setText(R.string.icon_user);
Iconify.addIcons(icon);

or this:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="12sp"
    android:id="@+id/icon_name"
    android:text="@string/icon_user"/>

What about Internationalization?

Is there any way to set the text from strings.xml ?

For example,

<IconTextView
    android:text="{fa-android} @string/string_name"
    ... />

minimum sdk version

What is the minimum Android SDK Version for this to work? Will work with ActionBarCompact?

IconTextView and IconButton should implement setText()

Currently the user has to call Iconify.addIcons() after each setText().
While this is fine for standard TextView, it should be implicit on IconTextView and IconButton.

Maybe I should add a listener on the provided TextView, but then I should provide a removeIcons() just in case.

Improve README

The README should highlight

  • Scalability
  • Shadows
  • Text colors

Cut word Kitkat

Cut out some words when I use IconTextView, if I use TextView works perfectly

screenshot_2014-09-15-13-47-08

screenshot_2014-09-15-13-49-06

XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal"
android:padding="10sp" >
<android.widget.IconTextView
android:id="@+id/iconTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

tested on Android 4.4.4 Moto G

Icon and text in two different lines

This is not an issue but rather a small silly doubt.
I want the text to appear below the icon and not on the left or right of the icon, how do i achieve this?

Use icons in EditText as drawables

This is somewhat of a question/feature request as I'm not sure if this is already possible. But what I would like to achieve in the first instance would be to have something like:

Where the drawableLeft could be taken from font awesome, alternatively a programmatic way would suffice. I tried using:
loginId.setCompoundDrawablesWithIntrinsicBounds(new IconDrawable(getActivity(), Iconify.IconValue.fa_adjust),0,0,0);

but it expects a drawable resource id.

Cheers

Possible memory inefficiency

I am wondering if assigning a new Drawable resource on each OnCreateOptionsMenu() in activity would lead to a new instance of the same Drawable being created (and the previous one floating around somewhere and causing memory leak). Is it better to create a Drawable myDrawable = new IconDrawable() in the activity constructor and re-use it?

    menu.findItem(R.id.action_notification).setIcon(
            new IconDrawable(this, Iconify.IconValue.fa_bell)
                    .colorRes(R.color.em_active_green)
                    .actionBarSize());

Add IconDrawable.getPaint()

This method could be useful in some case where developer want to set himself some configuration to Paint class, like setAntiAlias.

Of course you could provide a fluent API for each of Paint methods, but... I'm not sure it's a good solution :)

Exception while Running

I've been working on an application that uses android-iconify recently and was using IconButton and IconTextView which worked a few days ago. I noticed a new commit was made 2 hours ago and I believe is the cause of the issue. It looks like the Font was moved but the name was not updated and causes the following exception.

10-21 18:06:49.410 1741-1741/net.codesector.Mileage E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: net.codesector.Mileage, PID: 1741
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.codesector.Mileage/net.codesector.Mileage.LoginActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.IconTextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.IconTextView
at android.view.LayoutInflater.createView(LayoutInflater.java:621)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1929)
at net.codesector.Mileage.LoginActivity.onCreate(LoginActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
            at android.app.Activity.setContentView(Activity.java:1929)
            at net.codesector.Mileage.LoginActivity.onCreate(LoginActivity.java:14)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.(Typeface.java:175)
at android.graphics.Typeface.createFromFile(Typeface.java:159)
at com.joanzapata.android.iconify.Iconify.getTypeface(Iconify.java:80)
at com.joanzapata.android.iconify.Iconify.addIcons(Iconify.java:53)
at android.widget.IconTextView.init(IconTextView.java:46)
at android.widget.IconTextView.(IconTextView.java:36)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:595)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
            at android.app.Activity.setContentView(Activity.java:1929)
            at net.codesector.Mileage.LoginActivity.onCreate(LoginActivity.java:14)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

Support for spinning icons?

I was wondering how do i use spinning icons.

I tried with {fa-spinner fa-spin} and {fa-spinner} {fa-spin} but none of them worked.

So, am I going wrong somewhere or iconify doesn't support spinning icons?

Wrong icon name: fa_users

The icon "fa-group" is an alias for "fa-users", as seen here:
http://fortawesome.github.io/Font-Awesome/icon/users/

I understand that android-iconify will not support aliases for now. (+1 for that feature request, though!)

The problem is, the current version of android-iconify supports "fa-group" (the alias) and does NOT support "fa-users" (the actual non-alias icon). This causes me to need to support that one icon as an exception to the rule.

Compilation issue on second execution

I all the time got error "Multiple dex files define Landroid/widget/IconButton"

when i rebuild the project - everything works, but when i try to run second time, it fails.

I use gradle dependency:

compile 'com.joanzapata.android:android-iconify:1.0.6'

Any idea what can make this problem?

Visualizing icon on Graphics Preview

This is more a question then any other thing.

Can't see the icons rendered on the Graphics Preview, keep getting the following error:

The following classes could not be found:

  • IconTextView (Fix Build Path, Edit XML)

Is this the right thing? I'm doing something terrible wrong?
Eclipse ADT and Android Studio shows the same message error.

thanks

Change the TTF file

Hi there!

I would like to extend your project to allow the addition/usage of more TTF files. How can I open the library project on eclipse, edit it and then generate a new .jar file?

Button Icon

hy,
im trade to do this..

< Button
android:id="@+id/BtnAceptar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/descripcion_app"
android:layout_alignParentRight="true"
android:text="{fa-android}"
/>

but this render "{fa-android}" like button text, instead the icon

can someone help me please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.