use of com.facebook.drawee.span.SimpleDraweeSpanTextView in project fresco by facebook.
the class DraweeSpanSimpleTextFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
SimpleDraweeSpanTextView draweeSpanTextView = (SimpleDraweeSpanTextView) view.findViewById(R.id.drawee_text_view);
// The # will be replaced with the image.
String text = getString(R.string.drawee_span_simple_text);
int imagePosition = text.indexOf('#');
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder(text);
DraweeHierarchy draweeHierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setPlaceholderImage(new ColorDrawable(Color.RED)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(INLINE_IMAGE_URI).build();
draweeSpanStringBuilder.setImageSpan(getContext(), /* Context */
draweeHierarchy, /* hierarchy to be used */
controller, /* controller to be used to update the hierarchy */
imagePosition, /* image index within the text */
200, /* image width */
200, /* image height */
false, /* auto resize */
DraweeSpan.ALIGN_CENTER);
/* alignment */
draweeSpanTextView.setDraweeSpanStringBuilder(draweeSpanStringBuilder);
}
Aggregations