How to show complete Material style horizontal progressbar in pre lollipop devices applications.
By default material style progress bar cannot shows into pre lollipop devices like Kitkat, Jellybean, Ice cream sandwich..etc. But by the use of GitHub library we can easily Create Material Design horizontal Progress Bar in android application.
Follow all the below steps very carefully to add Material Design horizontal Progress Bar in your project.
1. Open your Project’s build.gradle ( Module : app ) and add com.android.support:appcompat-v7:23.4.0 library file.
2. Here is the code to add GitHub library inside build.gradle file.
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.1.+' compile 'me.zhanghai.android.materialprogressbar:library:1.1.6' }
Screenshot after add this code into build.gradle file.
Next step is start coding.
How to Create Material Design horizontal Progress Bar in android tutorial.
Code for MainActivity.java file.
package com.android_examples.materialhorizontal_pbar_android_examplescom; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
Code for activity_main.xml layout file.
<?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" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" android:orientation="vertical"> <me.zhanghai.android.materialprogressbar.MaterialProgressBar android:layout_width="fill_parent" android:layout_height="20dp" android:indeterminate="true" app:mpb_progressStyle="horizontal" style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="40dp" /> </RelativeLayout>
Screenshots :