Circular Fillable Loader in Android with Seekbar
Last Updated :
20 Aug, 2024
Circular Fillable Loader is an outstanding way of showing the ProgressBar in any Android app while loading. Display ProgressBar in another form is one of the best ways to increase the user experience. You can get to see these customize loaders in most of the apps. In this article, we are going to see how to implement Circular Fillable Loader in Android. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language.
Applications of Circular Fillable Loader
- A unique way of representing a ProgressBar in Android.
- Using a Circular Fillable Loader increases the user experience.
- Gives an animated look to our progress bar.
Attributes of Circular Fillable Loader
Attributes | Description |
---|
cfl_border | Use to give Border. |
cfl_border_width | Use to give width to the border. |
cfl_progress | Use to display the progress of the Circular Fillable Loader. |
cfl_wave_amplitude | Use to give amplitude to wave. |
cfl_wave_color | Use to give wave Color. |
Method 1
Step by Step Implementation
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
Step 2: Add dependency in build.gradle(Module:app) file
Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.
implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'
Step 3: Create a new State Progress Bar in your activity_main.xml file
Navigate to the app > res > layout to open the activity_main.xml file. Below is the code for the activity_main.xml file.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
tools:context=".MainActivity">
<!--Circular Fallible Loader-->
<com.mikhaellopez.circularfillableloaders.CircularFillableLoaders
android:id="@+id/circularFillableLoaders"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_baseline_android_24"
app:cfl_border="true"
app:cfl_border_width="12dp"
app:cfl_progress="80"
app:cfl_wave_amplitude="0.06"
app:cfl_wave_color="@color/purple_200" />
<!--Seek bar to increase fallible part-->
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/circularFillableLoaders"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp" />
</RelativeLayout>
Step 4: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
MainActivity.java
import android.os.Bundle;
import android.widget.SeekBar;
import androidx.appcompat.app.AppCompatActivity;
import com.mikhaellopez.circularfillableloaders.CircularFillableLoaders;
public class MainActivity extends AppCompatActivity {
// Variables Declared
CircularFillableLoaders circularFillableLoaders;
SeekBar seekBar;
int progress = 80;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Code for implementing Circular Fallible Loader
circularFillableLoaders = (CircularFillableLoaders) findViewById(R.id.circularFillableLoaders);
// Set Progress
circularFillableLoaders.setProgress(progress);
seekBar = findViewById(R.id.seekBar);
seekBar.setProgress(progress);
seekBar.setMax(100);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
// Set Progress
circularFillableLoaders.setProgress(progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
Now click on the run option it will take some time to build Gradle. After that, you will get output on your device as given below.
Output:
Method 2
Here we are going to implement the wave loading view. Here we are manually increasing the value of progress and the wave height is increasing. But It can also be used as a timer to set.
Step by Step Implementation
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
Step 2: Add dependency
Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.
implementation 'me.itangqi.waveloadingview:library:0.3.5'
Step 3: Working with the activity_main.xml file
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:layout_marginTop="20dp"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<me.itangqi.waveloadingview.WaveLoadingView
android:id="@+id/waveLoadingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:wlv_borderColor="@color/colorAccent"
app:wlv_borderWidth="3dp"
app:wlv_progressValue="40"
app:wlv_round_rectangle="true"
app:wlv_shapeType="circle"
app:wlv_titleCenter="Center Title"
app:wlv_titleCenterColor="@android:color/white"
app:wlv_titleCenterSize="24sp"
app:wlv_titleCenterStrokeColor="@android:color/holo_blue_dark"
app:wlv_titleCenterStrokeWidth="3dp"
app:wlv_triangle_direction="north"
app:wlv_waveAmplitude="70"
app:wlv_waveColor="@color/colorAccent" />
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100" />
</LinearLayout>
Step 4: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
MainActivity.java
import android.os.Bundle;
import android.widget.SeekBar;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
me.itangqi.waveloadingview.WaveLoadingView loadingView;
SeekBar seekBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initializing the layout
seekBar = findViewById(R.id.seekbar);
loadingView = findViewById(R.id.waveLoadingView);
// changing the progress value according the value changed in seekbar
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
loadingView.setProgressValue(progress);
String title = String.valueOf(progress);
loadingView.setBottomTitle("");
loadingView.setCenterTitle("");
loadingView.setTopTitle("");
if (progress < 50) {
// if progress is 50 then set bottom
// title as progress value
loadingView.setBottomTitle(title);
} else if (progress == 50) {
// if progress is 50 then set center
// title as progress value
loadingView.setCenterTitle(title);
} else {
// if progress is 50 then set top
// title as progress value
loadingView.setTopTitle(title);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
Output:
Similar Reads
How to Implement Circular ProgressBar in Android?
ProgressBar is used when we are fetching some data from another source and it takes time, so for the user's satisfaction, we generally display the progress of the task. In this article, we are going to learn how to implement the circular progress bar in an Android application using Java. So, this ar
5 min read
Discrete SeekBar in Android using Library
Discrete SeekBar is another most common feature that we can see in most of the apps. We can get to see this Discrete SeekBar in most of the music player apps, Rating apps, or for points given. Discrete SeekBar is one of the advanced systems of giving ratings instead of writing. In the previous artic
3 min read
How to Create CircularDialog in Android?
CircularDialog is another best way of representing information or data in an Android app. You can get to see these Circular Dialogs in most of the apps which are used to display the message of completion of the process in an attractive form. In this article, we are going to see how to implement Circ
3 min read
Discrete Seekbar in Android
Android discrete SeekBar is an extension of ProgressBar that has a draggable thumb. Users can use the thumb back and forth to set the current progress of the SeekBar. Discrete SeekBar works for discrete values. Â Step by Step Implementation Step 1: Create a New Project in Android Studio To create a n
3 min read
How to Create Circular Determinate ProgressBar in Android?
In this article, we are going to demonstrate how to create a circular progress bar in Android Studio that displays the current progress value and has a gray background color initially. Here progress is shown in the center of the Bar. A sample GIF is given below to get an idea about what we are going
5 min read
Circular Crop an Image and Save it to the File in Android
There are multiple applications available in the market that help in dealing with image processing, while most of them fail to produce very basic operations. Cropping is a simple application when one could resize an image by cutting it down. This task becomes complex when it comes to free-hand or sh
4 min read
Auto Image Slider in Android with Example
Auto Image Slider is one of the most seen UI components in Android. This type of slider is mostly seen inside the apps of big E-commerce sites such as Flipkart, Amazon, and many more. Auto Image Slider is used to represent data in the form of slides that change after a specific interval of time. In
6 min read
Android Auto Image Slider with Kotlin
Most e-commerce application uses auto image sliders to display ads and offers within their application. Auto Image Slider is used to display data in the form of slides. In this article, we will take a look at the Implementation of Auto Image Slider in our Android application using Kotlin. A sample v
5 min read
Creating a SeekBar in Android
Android SeekBar is a type of ProgressBar. On touching the thumb on seekbar and dragging it to the right or left, the current value of the progress changes. SeekBar is used for forwarding or backwarding the songs, Video etc. In the setOnSeekBarChangeListener interface is used which provides three met
3 min read
Material Search Bar in Android
A Material Search Bar is an essential component in modern Android applications, enhancing the user experience by allowing quick searches. Googleâs Material Design provides sleek, user-friendly search bars that blend well with UI/UX standards. This guide will help you integrate a Material Search Bar
4 min read