android-iconify icon indicating copy to clipboard operation
android-iconify copied to clipboard

FloatingActionButton how to

Open jaimeagudo opened this issue 8 years ago • 2 comments

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?

jaimeagudo avatar Feb 13 '17 19:02 jaimeagudo

You can use DroidAwesome library to use FontAwesome inside a FloatingActionButton

ghost avatar Mar 08 '17 11:03 ghost

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.

breenbob avatar Jun 06 '17 10:06 breenbob