GithubHelp home page GithubHelp logo

sibinjoseph111 / droidawesome Goto Github PK

View Code? Open in Web Editor NEW

This project forked from livin21/droidawesome

0.0 1.0 0.0 304 KB

An android library to display FontAwesome Icons in any View or a MenuItem

License: Apache License 2.0

Kotlin 93.31% Java 6.69%

droidawesome's Introduction

icon-96x96.png DroidAwesome

A library to display FontAwesome Icons in any View or a MenuItem

Download StackShare TravisCI Android Arsenal Codacy Badge

Views Supported:

  • TextView
  • AutoComplete TextView
  • EditText
  • Switch
  • CheckBox
  • Radio Button
  • Button
  • Toggle Button
  • ImageView
  • ImageButton
  • FloatingActionButton
  • MenuItem

Screenshot

Screenshot_1480330061.png Screenshot_1480244308.png

Gradle Setup

Add the following code snippet to module/build.gradle

dependencies {
    compile 'com.lmntrx.livin.library.droidawesome:droid-awesome:1.1.9'
}

Maven Setup

<dependency>
  <groupId>com.lmntrx.livin.library.droidawesome</groupId>
  <artifactId>droid-awesome</artifactId>
  <version>1.1.9</version>
  <type>pom</type>
</dependency>

How to use it?

Define required icons in res/values/icons.xml

<?xml version="1.0" encoding="utf-8"?>
  <resources>
    <string name="android_icon_font_awesome">&#xf17b;</string> //http://fontawesome.io/cheatsheet/
    <string name="not_allowed_font_awesome">&#xf05e;</string>
    <string name="fa_settings_gears">&#xf085;</string>
  </resources>

Now use custom view in activity.xml

<!-- Icons do not render in android studio render sandbox. Run project in an emulator to see changes -->
<com.lmntrx.livin.library.droidawesome.DroidAwesomeAutoCompleteTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="65sp"
        android:textColor="#0f0"
        android:gravity="center"
        android:text="@string/android_icon_font_awesome"/>

<com.lmntrx.livin.library.droidawesome.DroidAwesomeImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:text="@string/not_allowed_font_awesome"
        app:textColor="@color/colorAccent"
        app:textSize="38sp"/>
  • Or in java file
DroidAwesomeTextView textView = new DroidAwesomeTextView(context);
textView.setText(getString(R.string.your_icon_string));

Or

//TextView, EditText, Button, etc.
TextView textView = new TextView(context);
textView.setText(
                new DroidAwesome.StringBuilder(this)
                        .icon(getString(R.string.android_icon_font_awesome)) //icon
                        .build()
        );

//Imageview, ImageButton, FloatingActionButton, etc.
Imageview imageView = new Imageview(context);
imageView.setImageDrawable(
                new DroidAwesome.DrawableBuilder(this)
                        .color(R.color.colorPrimaryDark) //colorRes
                        .size(75f) //dimension float (sp)
                        .icon(getString(R.string.fa_settings_gears)) //icon
                        .build()
        );

To use with menu items

<!--XML-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.lmntrx.livin.droidawesome.MainActivity">
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        />
</menu>
//Java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem menuItem = menu.findItem(R.id.action_settings);
    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menuItem.setIcon(
                new DroidAwesome.DrawableBuilder(this)
                        .icon(getString(R.string.fa_settings_gears)) //icon
                        .color(R.color.colorAccent) //colorRes
                        .size(25f) //dimension float (sp)
                        .build()
        );
    return true;
}

ChangeLog

1.1.9

  • Removed use of font file from assets
  • Removed setFontFile() method

1.1.8

  • Minor Bug Fixes

1.1.7

  • Set Font Filename

1.1.6

  • Minor Bug Fix

1.1.5

  • Added DrawableBuilder and StringBuilder
  • Deprecated setFontIcon() and getFontIcon methods

1.1.4

  • Added setIcon() method to ImageView, ImageButton, FAB

1.1.3

  • Minor Bug Fixes
  • Updated build version and support library

1.1.2

  • Minor Bug Fix

1.1.1

  • Add FontAwesome icon programmatically
  • Added support for MenuItem

1.1.0

  • Added ImageView
  • Added ImageButton
  • Added FloatingActionButton

1.0.1

  • Minor Bug Fix

1.0.0

  • Added custom TextView
  • Added custom AutoComplete TextView
  • Added custom EditText
  • Added custom Button
  • Added custom ToggleButton
  • Added custom Switch
  • Added custom CheckBox
  • Added custom Radio Button

Credits

Icon designed by Aswin CJ

BehanceProfile GitHubProfile

Copyright

Copyright 2016 DroidAwesome - Livin Mathew

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.

droidawesome's People

Contributors

livin21 avatar jglanz avatar

Watchers

James Cloos avatar

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.