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

Add font awesome icons to a button in code

Open matthewkrueger opened this issue 8 years ago • 1 comments

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?

matthewkrueger avatar Apr 13 '16 19:04 matthewkrueger

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 the md-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.

JoanZapata avatar May 18 '16 06:05 JoanZapata