Fresco: Can I use Fresco with DataBinding or write image http url in xml?

Created on 23 Mar 2016  路  2Comments  路  Source: facebook/fresco

How to put image http url in placeholderImage by xml?

like this:
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/icon" android:layout_width="48dp" android:layout_height="48dp" fresco:placeholderImage="http://www.smemo.info/icon.png" />

with DataBinding:
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/icon" android:layout_width="48dp" android:layout_height="48dp" fresco:placeholderImage="@{imageBean.url}" />

enhancement

Most helpful comment

You can do it by adding a custom xml attribute with data binding and then loading the image in the (@BindingAdapter) annotated callback for that attribute. https://mpetersen3.wordpress.com/2016/09/09/data-binding-with-frescos-simpledraweeview/

All 2 comments

SimpleDraweeView is not "Data Binding compatible" at the moment and we don't have plan to do that in short period. In order to do so please feel free to create your pull request we'll be happy to approve.
Thanks

You can do it by adding a custom xml attribute with data binding and then loading the image in the (@BindingAdapter) annotated callback for that attribute. https://mpetersen3.wordpress.com/2016/09/09/data-binding-with-frescos-simpledraweeview/

Was this page helpful?
0 / 5 - 0 ratings