Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FloatingActionButton how to #196

Open
jaimeagudo opened this issue Feb 13, 2017 · 2 comments
Open

FloatingActionButton how to #196

jaimeagudo opened this issue Feb 13, 2017 · 2 comments

Comments

@jaimeagudo
Copy link

I hate to ask something I feel I'd have to research on my own but I feel lost. Is it possible to use the fontawesome ones inside FloatingActionButton directly?

@ghost
Copy link

ghost commented Mar 8, 2017

You can use DroidAwesome library to use FontAwesome inside a FloatingActionButton

@breenbob
Copy link

breenbob commented Jun 6, 2017

This works for me:

// For font awesome icon keys, look at cheat sheet: http://fontawesome.io/cheatsheet/
IconDrawable icon = new IconDrawable(getContext(), "fa-building");

// Default size is designed to suit normal sized FABs
if (myFab.getSize() == FloatingActionButton.SIZE_MINI) {
    icon.sizeDp(18);
    // Stretched by default, looks ok on normal sized ones but duff on mini ones
    myFab.setScaleType(ScaleType.CENTER);
}
myFab.setImageDrawable(icon);

I took this one step further and subclassed the FloatingActionButton to check for my own set of styleables, so I can set the fontAwesome icon key in XML with a custom attribute. Essentially it does the same as the above code, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants