Home

Awesome

:warning: This library was made years ago when it wasn't that easy to customize Android buttons like today. I highly recommend you to use Material Design button as it offers the same features and most importantly it's backed by the Android Team.


Fancybuttons

Icons, Borders, Radius ... for Android buttons jCenter jitPack Android Arsenal

<img src="/resources/cover.png" width="80%" alt="Android About Page Cover"/>

Overview

FancyButtons Android

Demo Application : Download APK

Features

Changelog

Installation

implementation 'com.github.medyo:fancybuttons:1.9.1'

To use font resources add support library to your dependencies:

implementation "com.android.support:appcompat-v7:$support_lib_version"

Usage

1 - Include FancyButtons namespace to the root element :

xmlns:fancy="http://schemas.android.com/apk/res-auto"

2 - Add the FancyButton View with custom params :

<mehdi.sakout.fancybuttons.FancyButton
android:id="@+id/btn_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

Supported Attributes

XML AttributeJava AttributeDescription
fancy:fb_textsetText(String)Text of the button
fancy:fb_textColorsetTextColor(int)Text Color of the button
fancy:fb_textSizesetTextSize(int)Size of the text
fancy:fb_textFontsetCustomTextFont(String)FontFamily of the text
fancy:fb_textFontRessetCustomTextFont(int)FontFamily of the text using font resource. REQUIRES support library
fancy:fb_textGravitysetTextGravity(Int)Gravity of the text
fancy:fb_iconResourcesetIconResource(Drawable)Drawable icon of the button
fancy:fb_iconPositionsetIconPosition(int)Position of the icon : Left, Right, Top, Bottom
fancy:fb_fontIconResourcesetIconResource(String)font icon of the button
fancy:fb_fontIconSizesetFontIconSize(int)Size of the icon
fancy:fb_iconFontsetCustomIconFont(String)FontFamily of the icon
fancy:fb_borderWidthsetBorderWidth(int)Width of the border
fancy:fb_borderColorsetBorderColor(int)Color of the border
fancy:fb_defaultColorsetBackgroundColor(int)Background color of the button
fancy:fb_focusColorsetFocusBackgroundColor(int)Focus Color of button background
fancy:fb_disabledColorsetDisableBackgroundColor(int)Disabled Color of button background
fancy:fb_disabledTextColorsetDisableTextColor(int)Disabled Color of button text
fancy:fb_disabledBorderColorsetDisableBorderColor(int)Disabled Color of button border
fancy:fb_radiussetRadius(int)Radius of the button
fancy:fb_radius(TopLeft, TopRight,BottomLeft,BottomRight)setRadius(int[] radius)Custom Radius for each button corner
fancy:fb_iconPaddingLeftsetIconPadding(int,int,int,int)Icon Padding
fancy:fb_iconPaddingRightsetIconPadding(int,int,int,int)Icon Padding
fancy:fb_iconPaddingTopsetIconPadding(int,int,int,int)Icon Padding
fancy:fb_iconPaddingBottomsetIconPadding(int,int,int,int)Icon Padding
fancy:fb_ghostsetGhost(boolean)Ghost (Hollow)
fancy:fb_useSystemFontsetUsingSystemFont(boolean)If enabled, the button title will ignore its custom font and use the default system font

Also you can use Attributes with default prefix (android:) which makes migrating of your project more fast. Default Attributes have more priority than Attributes with prefix fancy.

Supported default Attributes

XML Attribute
android:enabled
android:text
android:textSize
android:textAllCaps
android:fontFamily

Supported Getters

| Function | Description | | ------------- |:-------------:| -----:| | getText() | Returns Text Value of the button| | getTextViewObject() | Returns TextView Object| | getIconFontObject() | Returns icon defined by fb_fontIconResource| | getIconImageObject() | Returns icon defined by fb_iconResource |

Sample

1 - Spotify Button

FancyButton Spotify

<mehdi.sakout.fancybuttons.FancyButton
	android:id="@+id/btn_spotify"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:paddingBottom="10dp"
	android:paddingLeft="20dp"
	android:paddingRight="20dp"
	android:paddingTop="10dp"
	fancy:fb_borderColor="#FFFFFF"
	fancy:fb_borderWidth="1dp"
	fancy:fb_defaultColor="#7ab800"
	fancy:fb_focusColor="#9bd823"
	fancy:fb_fontIconResource="&#xf04b;"
	fancy:fb_iconPosition="left"
	fancy:fb_radius="30dp"
	fancy:fb_text="SHUFFLE PLAY"
	fancy:fb_textColor="#FFFFFF" />

2 - Facebook Button

FancyButton Facebook

FancyButton facebookLoginBtn = new FancyButton(this);
facebookLoginBtn.setText("Login with Facebook");
facebookLoginBtn.setBackgroundColor(Color.parseColor("#3b5998"));
facebookLoginBtn.setFocusBackgroundColor(Color.parseColor("#5474b8"));
facebookLoginBtn.setTextSize(17);
facebookLoginBtn.setRadius(5);
facebookLoginBtn.setIconResource("\uf082");
facebookLoginBtn.setIconPosition(FancyButton.POSITION_LEFT);
facebookLoginBtn.setFontIconSize(30);

See the example project for more samples

Bonus

Fancybuttons is delivered with :


FancyButtons AndroidFancyButtons AndroidFancyButtons Android

FAQ

How to add new fonts ? Just Paste your font inside assets/fonts/ folder for Text fonts or inside assets/iconfonts/ for icon fonts eg : entypo OR for text fonts add it to res/font/ and use android:fontFamily or fancy:fb_textFontRes to use it.

Contributions

Fancybuttons needs you to build the missing features :

Licence

MIT http://opensource.org/licenses/MIT

Developed By

El Mehdi Sakout

Follow @medyo80 on Twitter for the latest news.

For contact, shoot me an email at elmehdi.sakout@gmail.com