android-iconify
android-iconify copied to clipboard
Add font awesome icons to a button in code
Hi there - great library, been using it a long time.
I finally transitioned to 2.x from 1.x and I cannot get this code to work - it used to. What's going on?
StringBuilder builder = new StringBuilder();
builder.append("{");
builder.append(fontAwesomeIcon.key());
builder.append("}");
builder.append(" ");
builder.append(context.getString(buttonTextResource).toUpperCase());
button.setText(builder.toString());
Iconify.addIcons(button);
I see that "Iconify.addIcons" only takes TextViews, but this compiles, and it used to work on 1.x. Why doesn't it work anymore? The result now is that the icon will show as a small x inside a rectangle instead of the desired font awesome icon.
Note that if I change my Button to an IconButton, it works - however, this requires me to change about 100 buttons throughout my app. Why did it work before but not now? Is there a workaround?
It should work.
- What is the icon key? I know that one common issue is that
md_something
used to work on 1.x but 2.x only supports themd-something
format (with a dash). But IconButton doesn't allow it either so that would surprise me. - Can you try to use
textAllCaps="false"
on the button? The AllCaps flag disable all spans from the TextView or Button when applied.