Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nathan-fiscaletti/fa-android
✅ An implementation of Font Awesome in Android
https://github.com/nathan-fiscaletti/fa-android
android android-library android-studio android-ui font-awsome
Last synced: 17 days ago
JSON representation
✅ An implementation of Font Awesome in Android
- Host: GitHub
- URL: https://github.com/nathan-fiscaletti/fa-android
- Owner: nathan-fiscaletti
- License: mit
- Created: 2020-01-02T17:24:57.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-06T22:49:44.000Z (almost 5 years ago)
- Last Synced: 2024-11-18T22:05:04.843Z (3 months ago)
- Topics: android, android-library, android-studio, android-ui, font-awsome
- Language: Java
- Homepage:
- Size: 909 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Font Awesome for Android
An implementation of Font Awesome for Android Projects.
Learn more about Font Awesome [here](https://fontawsome.com)
[![](https://jitpack.io/v/nathan-fiscaletti/fa-android.svg)](https://jitpack.io/#nathan-fiscaletti/fa-android)
[![](https://jitpack.io/v/nathan-fiscaletti/fa-android/month.svg)](https://jitpack.io/#nathan-fiscaletti/fa-android)
[![GitHub license](https://img.shields.io/github/license/nathan-fiscaletti/fa-android.svg?color=blue)](https://github.com/nathan-fiscaletti/fa-android/blob/master/LICENSE)
![FA Version](https://img.shields.io/badge/FA-5.13-blue)![Logo](./images/logo.png)
## Install Font Awesome for Android into your Android application
1. In your **project level** `build.gradle` add the repository
```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
2. In your **module level** `build.gradle` add the library (find the version numbers [here](https://github.com/nathan-fiscaletti/fa-android/releases))```gradle
dependencies {
...
implementation 'com.github.nathan-fiscaletti:fa-android:LATEST_VERSION'
}
```
After installing the library, in your target (not in the fontawesome target), you will need to create a directory for the font assets.1. Create a directory in `your_app/src/main` called `assets`.
2. Within the `assets` directory create a directory called `fonts`.
3. Download your web fonts from font awesome and move either your free or pro font awesome font files into the assets directory, this project supports both. You should specifically move the `.ttf` font files. For Font Awesome 5.12.0 they are stored within the `webfonts` directory of the zip file you download.The final directory structure should look like this:
![File Structure Preview](./images/preview.png)
## General Usage
### Adding a FATextView in your XML Layout
```xml
```### Create an FATextView in Java
```java
FATextView faTextView = new FATextView(context);
```**OR**
```java
FATextView faTextView = new FATextView(context, R.string.fa_check_circle, FATypeface.FAType.Solid, true);
```> The parameters are in the following order: The Context, the Icon, The Icon Type, true for autosize. If you set autosize to false when initializing it, you can later opt to autosize it using `faTextView.autoSizeIcon();`.
### Controlling the Icon
To change the icon set `fa_icon` to `@string/fa_...` where `...` is the name of the icon you would like to use. You can also control the type of icon used using the `fa_type` property with one of the following: `solid`, `light`, `regular`, or `brands`.
Alternately, if you are working in code, you can use the following functions:
```java
faTextView.setIcon(R.string.fa_check_circle);
faTextView.setTypeface(FATypeface.FAType.Solid);
```> You can control the icon color using `android:textColor`.
### Controlling the Icon Size
![SizePreview](./images/size_demo.gif)
There are two ways to control the size of the icon.
* Use `wrap_content` for both the **width** and **height** of your view, and control the icon size using `android:textSize="XXsp".
* Do not use `android:textSize` at all, and instead explicitly set **width** and **height**.When using `wrap_content`, the icon will follow the `android:textSize` property for sizing.
When using explicate sizes, the icon will automatically scale to the size of the view.> You can opt to turn off auto-sizing using `app:fa_autosize="false"`.