Fresco: Round progressbar

Created on 28 Dec 2015  ·  4Comments  ·  Source: facebook/fresco

Hi friends,
I has a question, in my app I using SimpleDraweeView and I want use round progressbar override when SimpleDraweeView load image.
plz help me.
my code:
android:layout_width="match_parent"
android:layout_height="wrap_content">

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/adapter_detail_iv"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:visibility="gone"
            fresco:placeholderImage="@drawable/bg_default_loading_image" />

        <LinearLayout
            android:id="@+id/layout_progressbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="#33000000"
            android:gravity="center"
            android:orientation="vertical"
            android:visibility="gone">

            <ProgressBar
                android:id="@+id/indeterminate_progress_large_library"
                style="@style/Widget.MaterialProgressBar.ProgressBar.Small"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:indeterminate="true"
                android:visibility="gone" />
        </LinearLayout>
    </FrameLayout>

Most helpful comment

@cazador4 I tried to implement your CircleProgressBarDrawable, but instead of circle shape I get Oval. What could be the problem? Maybe because my DraweeView is not square?

All 4 comments

alternatively, fresco has an indeterminate progress indicator already. U can use AutoRotateDrawable for ProgressBarDrawable.

@cazador4 I tried to implement your CircleProgressBarDrawable, but instead of circle shape I get Oval. What could be the problem? Maybe because my DraweeView is not square?

@cazador4 I tried to implement your CircleProgressBarDrawable, but instead of circle shape I get Oval. What could be the problem? Maybe because my DraweeView is not square?

That might be the problem.
Anyway, use

setPlaceholderImage(
                        AutoRotateDrawable(
                            ContextCompat.getDrawable(
                                postMediaHolder.context,
                                R.drawable.ic_refresh
                            ), 1000
                        ), ScalingUtils.ScaleType.CENTER
                    )

And it should center, fix aspect ratio and scaling of the drawable.

Was this page helpful?
0 / 5 - 0 ratings