Material Design Components Progress Indicator in Android
Material Design Components (MDC Android) offers designers and developers a way to implement Material Design in their Android applications. Developed by a core team of engineers and UX designers at Google, these components enable a reliable development workflow to build beautiful and functional Android applications. Material design in Android is one of the key features that attracts and engages the customer towards the application. This is a special type of design, which is guided by Google. So in this article, it has been demonstrated how to use Progress Indicators, their types, and anatomy.
Create an empty activity project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Add Required Dependency
Include google material design components dependency in the build.gradle file. After adding the dependencies don’t forget to click on the “Sync Now” button present at the top right corner.
Note that while syncing your project you need to be connected to the network and make sure that you are adding the dependency to the app-level Gradle file as shown below.
What are Progress Indicators?
Progress indicators are used in android to inform the user about ongoing processes, for example, loading applications, network calls, downloading or uploading files. These communicate the app’s state and inform the user whether they can navigate away from the current session of the app.
Types of Progress Indicators
There are majorly two types of Progress Indicators one is a linear indicator and another is a circular indicator. Have a look at the following image to get the difference. These progress indicators may be Determinate or Indeterminate.
- Determinate indicators inform the user about the definite process, these should be only used when the process rate can be detected.
- Indeterminate indicators inform the user about the indefinite process means the current process is can take an indefinite time to complete.
The Linear Progress indicator Consists of two major components:
- Track: The component which is of fixed width, which sets boundaries for the indicator to travel along.
- Indicator: The component which animates along the track.
Steps to implement the progress indicator in the Android project
Working with the activity_main.xml file
The main layout of the application consists of two progress indicators. One is a Linear progress indicator and another is a Circular progress indicator. Note that the indeterminate attribute in each of them to be true, otherwise it will not animate when the app is run on an emulator. To implement the same invoke the following code inside the activity_main.xml file.
Customizing Linear progress indicator:
To change the track thickness, track color, and indicator color the attributes are:
Following is an example:
Increasing the size of the track thickness, track color, and indicator size for circular progress indicator:
To change the track color, indicator color, track thickness, and indicator size the attributes are:
Following is an example:
Some common attributes of linear and circular indicators are:
|Track corner radius||app:trackCornerRadius|
|Show animation behavior||app:showAnimationBehavior|
|Hide animation behavior||app:hideAnimationBehavior|
Specific Attributes for Linear progress indicator:
These attributes are specific for Linear Progress indicators.
|Indeterminate animation type||app:indeterminateAnimationType|
Specific Attributes for Circular progress indicator:
These attributes are specific for Circular Progress indicators.
|Spinner size (outer diameter)||app:indicatorSize|
Please Login to comment...