IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts.

Related tags

UI/UX IconicDroid
Overview

IconicDroid Build Status Android Arsenal

IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts.

Try out the sample application on the Google Play. IconicDroid example

Usage

Including in your project

IconicDroid is presented as an Android library project. It is not a standalone JAR because fonts are stored as a raw resources.

You can include this project by referencing it as a library project in Eclipse or ant.

Sample usage

Code:

IconicFontDrawable iconicFontDrawable = new IconicFontDrawable(getContext());
iconicFontDrawable.setIcon(EntypoSocialIcon.GITHUB);
iconicFontDrawable.setIconColor(Color.GREEN);

findViewById(R.id.some_view).setBackground(iconicFontDrawable);

Available fonts

License

Note that all fonts have their own license.

Comments
  • Icons are drawn twice on the Kindle

    Icons are drawn twice on the Kindle

    For some reason two of each icon are displayed. one on top of the other on the kindle. This is happening on my app and also the sample app this repo.

    Please see these images as an example http://imgur.com/a/E6l2V

    The icon starts off doubled then when I select a different icon from the spinner, it doesn't remove the old one, it just ads it on top

    All icons in my app are doubled on top of each other.

    I played around with the library and my wild wild guess is invalidateSelf() but I don't know

    opened by Brblol 4
  • FontAwesome icons out-of-date

    FontAwesome icons out-of-date

    The icons in the FontAwesomeIcon.java file and the font file itself are out of date... If you look at the FontAwesome website, you will find a lot of icons that I can't use...

    Particularly, I downloaded the font file from the website and started mapping again the characters that I'm using...

    opened by tuliohmendes 3
  • Icon rendering is broken on Kindle Fire HDX

    Icon rendering is broken on Kindle Fire HDX

    Icons are garbled on 7" Kindle Fire HDX. See attached screenshots. Not all fonts are equally affected: fontawesome and iconic are completely broken while entypo is kind of ok, but not really - there are still rendering artifacts, as if canvas is not properly cleaned up on repaints. screenshot_2015-01-08-09-14-24 screenshot_2015-01-08-09-14-54 screenshot_2015-01-08-09-14-42 screenshot_2015-01-08-09-16-00

    opened by itkach 2
  • Setting Icon as DrawableLeft or Right

    Setting Icon as DrawableLeft or Right

    I'm dealing with your project and first is all, for me it is very usefull. But... I want to attach a single icon as an DrawableLeft/DrawableRight etc. but it doesn't work. My code

        IconicFontDrawable iconicFontDrawable = new IconicFontDrawable(this);
        iconicFontDrawable.setIcon(EntypoSocialIcon.GITHUB);
        iconicFontDrawable.setIconColor(Color.BLACK);
        TextView v = (TextView) findViewById(R.id.textview);
        if (v != null) {
            T.setBackground(iconicFontDrawable);
            T.setCompoundDrawables(null,null, iconicFontDrawable, null);
            T.setCompoundDrawablesWithIntrinsicBounds(null, null, iconicFontDrawable, null);
        }
    

    Only setBackgrounds() works, but not the two other methods. But why is it so? I mean, neither Eclipse nor Android Studio complains about these methods in that way.

    opened by darkbutton 2
  • Easy addition of other fonts

    Easy addition of other fonts

    I modified the library to be easier to add new TrueTrype files:

    Now there are two classes, TypefaceManager and IconicFontDrawable

    package com.atermenji.android.iconicdroid;

    import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Hashtable;

    import android.content.Context; import android.content.res.Resources.NotFoundException; import android.graphics.Typeface; import android.util.Log;

    class TypefaceManager {

    private static Hashtable<Integer, Typeface> typefaces = new Hashtable<Integer, Typeface>();
    
    private static final String TAG = "TypefaceManager";
    
    
    public TypefaceManager() {
    }
    
    public Typeface removeTypeFace(int typefaceResourceId){
        return typefaces.remove(typefaceResourceId);
    }
    
    public Typeface getTypeFace(Context context, int typefaceResourceId){
        Typeface typeface = typefaces.get(typefaceResourceId);
        if(typeface == null){
            typeface = createTypefaceFromResource(context, typefaceResourceId);
            typefaces.put(typefaceResourceId, typeface);
        }
        return typeface;
    }
    
    private static Typeface createTypefaceFromResource(Context context, final int resource) {
        Typeface typeface = null;
        InputStream inputStream = null;
        OutputStream outputStream = null;
    
        try {
            inputStream = context.getResources().openRawResource(resource);
        } catch (NotFoundException ex) {
            Log.e(TAG, "Could not find typeface in resources.", ex);
        }
    
        String outPath = context.getCacheDir() + "/tmp.raw";
    
        try {
            byte[] buffer = new byte[inputStream.available()];
            outputStream = new BufferedOutputStream(new FileOutputStream(outPath));
    
            int l = 0;
            while ((l = inputStream.read(buffer)) > 0) {
                outputStream.write(buffer, 0, l);
            }
    
            typeface = Typeface.createFromFile(outPath);
    
            new File(outPath).delete();
        } catch (IOException ex) {
            Log.e(TAG, "Error reading typeface from resource.", ex);
        } finally {
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
                if (outputStream != null) {
                    outputStream.close();
                }
            } catch (IOException ex) {
                Log.e(TAG, "Error closing typeface streams.", ex);
            }
        }
    
        return typeface;
    }
    

    }

    /*

    • Copyright (C) 2013 Artur Termenji *
    • 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. */ package com.atermenji.android.iconicdroid;

    import android.content.Context; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Typeface; import android.graphics.drawable.Drawable;

    //import com.atermenji.android.iconicdroid.icon.Icon;

    /**

    • A custom {@link Drawable} which can display icons from icon fonts. */ public class IconicFontDrawable extends Drawable {

    // private Context mContext;

    private Paint mIconPaint;
    private Paint mContourPaint;
    
    private Rect mPaddingBounds;
    private RectF mPathBounds;
    
    private Path mPath;
    
    private int mIconPadding;
    private int mContourWidth;
    
    private int mIntrinsicWidth;
    private int mIntrinsicHeight;
    
    private boolean mDrawContour;
    

    // private Font mIcon;
    private char[] mIconUtfChars;

    private IconicFontDrawable() {
    

    // mContext = getContext().getApplicationContext();

        mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    
        mContourPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mContourPaint.setStyle(Paint.Style.STROKE);
    
        mPath = new Path();
    
        mPathBounds = new RectF();
        mPaddingBounds = new Rect();
    }
    

    IconicFontDrawable(Typeface typeface, int utfValue) { this(); updateIcon(typeface, utfValue); }

    /**
     * Loads and draws given {@link Font}.
     *
     * @param icon
     */
    public void setIcon(Typeface typeface, int utfValue) {
        updateIcon(typeface, utfValue);
        invalidateSelf();
    }
    
    /**
     * Set a color for the {@link Font}.
     *
     * @param color
     */
    public void setIconColor(int color) {
        mIconPaint.setColor(color);
        invalidateSelf();
    }
    
    /**
     * Set a padding for the {@link Font}.
     *
     * @param iconPadding
     */
    public void setIconPadding(int iconPadding) {
        mIconPadding = iconPadding;
        if (mDrawContour) {
            mIconPadding += mContourWidth;
        }
    
        invalidateSelf();
    }
    
    /**
     * Set contour params for the {@link Font}.
     * You should call {@link #drawContour(boolean)} method to enable contour.
     *
     * @param contourColor
     * @param contourWidth
     */
    public void setContour(int contourColor, int contourWidth) {
        setContourColor(contourColor);
        setContourWidth(contourWidth);
        invalidateSelf();
    }
    
    /**
     * Set contour color for the {@link Font}.
     * You should call {@link #drawContour(boolean)} method to enable contour.
     *
     * @param contourColor
     */
    public void setContourColor(int contourColor) {
        mContourPaint.setColor(contourColor);
        invalidateSelf();
    }
    
    /**
     * Set contour width for the {@link Font}.
     * You should call {@link #drawContour(boolean)} method to enable contour.
     *
     * @param contourWidth
     */
    public void setContourWidth(int contourWidth) {
        mContourWidth = contourWidth;
        mContourPaint.setStrokeWidth(mContourWidth);
        invalidateSelf();
    }
    
    /**
     * Enable/disable contour drawing.
     *
     * @param drawContour
     */
    public void drawContour(boolean drawContour) {
        mDrawContour = drawContour;
    
        if (mDrawContour) {
            mIconPadding += mContourWidth;
        } else {
            mIconPadding -= mContourWidth;
        }
    
        invalidateSelf();
    }
    
    /**
     * Set intrinsic width, which is used by several controls.
     *
     * @param intrinsicWidth
     */
    public void setIntrinsicWidth(int intrinsicWidth) {
        mIntrinsicWidth = intrinsicWidth;
    }
    
    /**
     * Set intrinsic height, which is used by several controls.
     *
     * @param intrinsicHeight
     */
    public void setIntrinsicHeight(int intrinsicHeight) {
        mIntrinsicHeight = intrinsicHeight;
    }
    
    @Override
    public void draw(Canvas canvas) {
    

    // if (mIcon != null) { final Rect viewBounds = getBounds();

            updatePaddingBounds(viewBounds);
            updateTextSize(viewBounds);
            offsetIcon(viewBounds);
    
            mPath.close();
    
            if (mDrawContour) {
                canvas.drawPath(mPath, mContourPaint);
            }
    
            canvas.drawPath(mPath, mIconPaint);
    

    // } }

    @Override
    public int getIntrinsicWidth() {
        return mIntrinsicWidth;
    }
    
    @Override
    public int getIntrinsicHeight() {
        return mIntrinsicHeight;
    }
    
    @Override
    public int getOpacity() {
        return PixelFormat.OPAQUE;
    }
    
    @Override
    public void setAlpha(int alpha) {
        mIconPaint.setAlpha(alpha);
    }
    
    @Override
    public void setColorFilter(ColorFilter cf) {
        mIconPaint.setColorFilter(cf);
    }
    
    private void updateIcon(Typeface typeface, int utfValue) {
      mIconUtfChars = Character.toChars(utfValue);  
      mIconPaint.setTypeface(typeface);
    

    }

    private void updatePaddingBounds(Rect viewBounds) {
        if (mIconPadding >= 0
                && !(mIconPadding * 2 > viewBounds.width())
                && !(mIconPadding * 2 > viewBounds.height())) {
            mPaddingBounds.set(
                    viewBounds.left + mIconPadding,
                    viewBounds.top + mIconPadding,
                    viewBounds.right - mIconPadding,
                    viewBounds.bottom - mIconPadding);
        }
    }
    
    private void updateTextSize(Rect viewBounds) {
        float textSize = (float) viewBounds.height() * 2;
        mIconPaint.setTextSize(textSize);
    
        mIconPaint.getTextPath(mIconUtfChars, 0, mIconUtfChars.length,
                0, viewBounds.height(), mPath);
        mPath.computeBounds(mPathBounds, true);
    
        float deltaWidth = ((float) mPaddingBounds.width() / mPathBounds.width());
        float deltaHeight = ((float) mPaddingBounds.height() / mPathBounds.height());
        float delta = (deltaWidth < deltaHeight) ? deltaWidth : deltaHeight;
        textSize *= delta;
    
        mIconPaint.setTextSize(textSize);
    
        mIconPaint.getTextPath(mIconUtfChars, 0, mIconUtfChars.length,
                0, viewBounds.height(), mPath);
        mPath.computeBounds(mPathBounds, true);
    }
    
    private void offsetIcon(Rect viewBounds) {
        float startX = viewBounds.centerX() - (mPathBounds.width() / 2);
        float offsetX = startX - mPathBounds.left;
    
        float startY = viewBounds.centerY() - (mPathBounds.height() / 2);
        float offsetY = startY - (mPathBounds.top);
    
        mPath.offset(offsetX, offsetY);
    }   
    
    
    public static IconicFontDrawable getDrawable(Context context, int typefaceResourceId, int utfValue){
        Typeface typeface = new TypefaceManager().getTypeFace(context, typefaceResourceId);     
        IconicFontDrawable drawable = new IconicFontDrawable(typeface, utfValue);
        return drawable;
    }
    

    }

    To use jut put the .ttf file(s) inside res/raw and, in Eclipse, choose Project->Clean... option.

    IconicFontDrawable drawable = IconicFontDrawable.getDrawable(mContext, R.raw.roboto_bold, '$'); // you also can use the hex value of the character instead of a char as the second argument.

    opened by Natanael1234 0
  • Unable to scale Icons

    Unable to scale Icons

    The functions setIntrinsicHeight and setIntrinsicWidth doesn't work in my case. I want to stretch an icon with a height of 75 and a width of 300. code

    TextView v= (TextView) findViewById(R.id.textView1);
        IconicFontDrawable iconicFontDrawable = new IconicFontDrawable(getApplicationContext());
        iconicFontDrawable.setIcon(FontAwesomeIcon.TOOGLE_ON);
        iconicFontDrawable.setIconColor(Color.BLACK);
        iconicFontDrawable.setIntrinsicHeight(75);
        iconicFontDrawable.setIntrinsicWidth(300);
    v.setCompoundDrawablesWithIntrinsicBounds(iconicFontDrawable, null, null, null);
    
    opened by darkbutton 0
  • Add IconicFontButton and supporting code.

    Add IconicFontButton and supporting code.

    This PR adds support for a new class, IconicFontButton. It's an Android button with built in support for an IconicDroid background, customizable via plain XML. It's a little rough around the edges, but worked for my purposes. That said, I'm happy to make changes. If we merge this, we should consider updating the demo to show the new functionality simply by adding the following to a layout file:

    <com.atermenji.android.iconicdroid.IconicFontButton
        style="@style/IconicFontButton"
        app:iconUtf="@string/awesome_plus_square_o"
        app:font="awesome" />
    
    opened by niedzielski 2
Owner
Artur Termenji
Artur Termenji
Drawing App: A simple drawing application that allows the user to draw using a pencil or using shapes

Drawing-App Drawing app is a simple drawing application that allows the user to

Nada Feteiha 1 Oct 5, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Dec 30, 2022
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

David Schreiber-Ranner 1.1k Nov 10, 2022
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

Patrick Favre-Bulle 1k Dec 1, 2022
A View on which you can freely draw, customizing paint width, alpha and color, and take a screenshot of the content. Useful for note apps, signatures or free hand writing.

FreeDrawView A View that let you draw freely on it. You can customize paint width, alpha and color. Can be useful for notes app, signatures or hands-f

Riccardo Moro 643 Nov 28, 2022
Bootstrap style widgets for Android, with Glyph Icons

Android-Bootstrap Android Bootstrap is an Android library which provides custom views styled according to the Twitter Bootstrap Specification. This al

Bearded Hen 7.3k Jan 3, 2023
:octocat: Drawable of badge.

Badge Preview Integration Add the JitPack repository to your root build.gradle: repositories { maven { url "https://jitpack.io" } } Add the depend

nekocode 952 Dec 8, 2022
A simple library to let you sign (or draw lines) smoothly with your finger into a view and save it.

FingerSignView Introduction FingerSignView is a simple library that lets you finger, or draw lines, smoothly with your finger into a View and save it

Agnaldo Pereira 25 Nov 20, 2022
Android layout decorators : Injecting custom attributes in layout files, Using decorators to get rid of unnecessary class explosion with custom views

Decor Decor is a library that applies decorators to Android layout with additional attributes without the need to extend and create a custom View for

Mouna Cheikhna 304 Nov 25, 2022
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

Jake Klinker 1.3k Nov 25, 2022
💳 CreditCardView is an Android library that allows developers to create the UI which replicates an actual Credit Card.

CreditCard View CreditCardView is an Android library that allows developers to create the UI which replicates an actual Credit Card. Displaying and en

Vinay Gaba 769 Dec 14, 2022
Custom UI control for android which is showing data as a segments and a value inside them.

Segmented Bar View for Android Custom UI control for android which is showing data as a segments and a value inside them. Screenshots Install From rep

GSPD 354 Nov 10, 2022
A custom view, in which device contact list is displayed

Getting Started This repository contains a custom view, in which device contact list is displayed Implementation Go to Settings.gradle, inside reposit

Ankit Kumar 2 May 7, 2022
Android-ScrollBarPanel allows to attach a View to a scroll indicator like it's done in Path 2.0

Path 2.0 like ScrollBarPanel for Android Android-ScrollBarPanel allows to attach a View to a scroll indicator like it's done in Path 2.0. Features Sup

Arnaud Vallat 551 Dec 22, 2022
Android view that allows the user to create drawings. Customize settings like color, width or tools. Undo or redo actions. Zoom into DrawView and add a background.

DrawView Android view that allows the user to create drawings. Draw anything you like in your Android device from simple view. Customize draw settings

Oscar Gilberto Medina Cruz 839 Dec 28, 2022
A view that allows to paint and saves the result as a bitmap

Android Drawable View Sample app: An Android view that allows to paint with a finger in the screen and saves the result as a Bitmap. Importing to your

Christian Panadero 581 Dec 13, 2022
The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months

Custom-Calendar-View To use the CustomCalendarView in your application, you first need to add the library to your application. You can do this by eith

Nilanchala Panigrahy 113 Nov 29, 2022
Allows you to launch various /hidden/ options of the Oculus Quest (2)

vrLauncher Allows you to launch various /hidden/ options of the Oculus Quest (2) Using it Sideload the apk onto your Oculus Quest (2) Choose the optio

Bastian 153 Dec 25, 2022
Custom android music player view.

InteractivePlayerView Custom android music player view. Screen Check it on youtube Usage(XML) Define it in your xml file. <co.mobiwise.library.Intera

Mert Şimşek 744 Dec 25, 2022