FontAwesomeIcon is a simple library to use FontAwesome on Android.
This library only aims to provide to use FontAwesome Icon very simply.
So please customize your own layout with FontAwesomeIcon.
FaIcon icon = new FaIcon(context);
icon.setIcon("fa-search");
icon.setColor(Color.argb(20, 128, 00, 00));
icon.setSize(context.getResources().getDimension(R.dimen.sample));
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:faicon="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<com.teamhiroq.libs.fontawesomeicon.FaIcon
android:layout_width="wrap_content"
android:layout_height="wrap_content"
faicon:faSize="@dimen/sample"
faicon:faIcon="fa-search"
faicon:faColor="#14800000"/>
</LinearLayout>
xmlns |
---|
xmlns:faicon="http://schemas.android.com/apk/res-auto" |
Attribute Name | Related Method | Description |
---|---|---|
faicon:faSize | setSize(float size) | Specify font size. Format is completely same as TextSize like @dimen/width , 10dp , 13sp |
faicon:faIcon | setIcon(String name) | Specify an icon name. Please refer to support names |
faicon:faColor | setColor(int color) | Specify a icon color. Format is completely same as TextColor like @color/red , #FF303030 (ARGB), #303030 (RGB) |
FontAwesome 4.2.0 Icons
- Move to project path
cd path_to_project
- Checkout FontAwesomeIcon and add git submodule
git submodule add https://github.com/hiroq/FontAwesomeIcon.git
If your project does not have own git repository, use this command git clone https://github.com/hiroq/FontAwesomeIcon.git
instead.
- Configure to include FontAwesome
Appendinclude ':FontAwesomeIcon:lib'
to "./settings.gradle".
Sample is below:
include ':app'
include ':FontAwesomeIcon:lib'
- Configure to compile FontAwesome
Appendcompile project(':FontAwesomeIcon:lib')
to "./app/build.gradle".
Sample is below:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':FontAwesomeIcon:lib')
}
- Copy TRUE TYPE FONT to your assets dir
cd path_to_project
cp ./FontAwesomeIcon/fontawesome-webfont.ttf ./app/src/main/assets/
- Clone FontAwesomeIcon to anywhere
- Copy FaIcon.java and FontAwesome.java to your project. Please make package directories before coping.
- Copy fontawesome-webfont.ttf to your project assets directory.
To execute following commands, you can fetch the latest FontAwesome to your local library.
cd FontAwesomeIcon/generator
chmod +x ./generator.sh
./generator.sh
NOTE : Please make sure that your computer is Linux/Mac and PHP is installed before to run above generator.sh