Using the "Animated Circle" in an Imageview While Loading Stuff

Using the animated circle in an ImageView while loading stuff

Simply put this block of xml in your activity layout file:

<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>

And when you finish loading, call this one line:

findViewById(R.id.loadingPanel).setVisibility(View.GONE);

The result (and it spins too):

Sample Image

Add loading circle animation while images are loaded

Have a progressbar in each list item. Whenever you image gets downloaded, hide this progressbar[ set visibility GONE]. Your xml should look something

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/imgToBeSet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/img_cont_desc_common" />

<ProgressBar
android:id="@+id/imgProgress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/textMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imgToBeSet"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:text="@string/msg_download_failed" />

</RelativeLayout>

Additionally i have a text view which is show if the download fails, in your case you can remove this text view and show the default image and hide the progressbar if download fails.

How to add loading circle animation to image in recycerview before load android

You are required to add a progress bar on the top of the RecylerView item layout.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />

<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView3"
app:layout_constraintEnd_toEndOf="@+id/imageView3"
app:layout_constraintStart_toStartOf="@+id/imageView3"
app:layout_constraintTop_toTopOf="@+id/imageView3" />
</androidx.constraintlayout.widget.ConstraintLayout>

Now inside your RecyclerViewAdapter's onBindViewHolder(ViewHolder holder, int position) method.

Add this code:

holder.progressBar.setVisibility(View.VISIBLE);

Change this code:

Picasso.with(ct)
.load(listData.getImageurl())
.into(holder.img);

To:

Picasso.with(ct)
.load(listData.getImageurl())
.into(holder.img, new Callback(){
@Override
public void onSuccess() {
holder.progressBar.setVisibility(View.GONE);
}

@Override
public void onError() {
holder.progressBar.setVisibility(View.GONE);
}
});

And also update your ViewHolder Too.

Show fill animation in imageView while loading the image from server android

This library might be what you need.

How to create an indefinite gradient loading like animated view?

Animation needs some fractional data, so just binary switch actually does not work - it is just a toggle.

A possible approach is to construct positional gradient and let animation know that some of color position in gradient is changed, so animatable. This can be done with AnimatableModifier.

Here is a demo (Xcode 13.4 / iOS 15.5)

Sample Image

Main part:

    RoundedRectangle(cornerRadius: 12).fill(.clear)
.modifier(GradientProgressEffect(position: animate))
.animation(.linear(duration: 2.0)
.repeatForever(autoreverses: true), value: animate)
.onAppear {
animate = 0.9
}

// ...

LinearGradient(
stops: [
.init(color: .gray.opacity(0.1), location: 0.0),
.init(color: .gray.opacity(1), location: position - 0.05),
.init(color: .gray.opacity(1), location: position + 0.05),
.init(color: .gray.opacity(0.1), location: 1.0),
],
startPoint: .leading,
endPoint: .trailing
)

*constants can be fit per needs

Complete test module is here

How to show loading spinner in activity while this activity is loading(Xamarin.Android)?

you first add a nuget pack like "urlimageviewhelper", that works fine for me
then use this code instead common way

    Koush.UrlImageViewHelper.SetUrlDrawable(ImageViewSample, "ImageUrl", Resource.Drawable.Preloaing, IntNumber);

in the above code use 600000 for 10 minus cache Imgae

Resource.Drawable.Preloaing: it's preload image

So the activity loads fast and image show after loading



Related Topics



Leave a reply



Submit