JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 527 forks source link

Render icons in preview mode in Android Studio #152

Closed gurachan closed 8 years ago

gurachan commented 8 years ago

hmmm is it posible to render it on display ?

when you put android:text="{fa-envelope-o 19dp}"

it will only render on phone :( but not on preview

because i need to run and run to check if icons are perfectly align ..

JoanZapata commented 8 years ago

It would be a nice thing to have. Unfortunately I think it would be very complex.

1zaman commented 8 years ago

There are two reasons why this doesn't work:

  1. The preview doesn't load assets from library projects.
  2. The font modules need to be registered so that the widget can find the icon. Usually, this is done at application initialization time, but those callbacks are not invoked by the preview.

I worked around these issues in the edX project thus:

  1. Added the TTF file for my font in my project's assets at the same path as in the font module, and with the same name.
  2. Extended all the icon widget classes, added a static initializer in them which registers my font modules, and used these classes everywhere in XML layout definitions (e.g. IconTextViewXml).
JoanZapata commented 8 years ago

@1zaman I'm sorry to hear that, it looks like a painful process.

Unfortunately I don't think that can be provided by the lib, so I'm closing this issue. Hopefully @Dj-jom2x you can now test a lot more faster with Instant Run.

1zaman commented 8 years ago

Yeah, the second issue could be solved by having the font module classes registered statically in a properties file which is read from a static initializer in the Iconify class, but the first issue can't be solved from the library itself. I have logged a bug report on it at http://b.android.com/202208. Hopefully, it will be fixed in a future version of Studio, at which point this ticket might be reopened.