Thursday, 21 May 2015

Custom Progress bar In Android

Create a Project:
 Step 1: Copy Paste Following Code into
 Main activity

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;


public class ProgressbarActivity extends Activity {

ProgressBar progressbar_round;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_progressbar);
progressbar_round = (ProgressBar) findViewById(R.id.progressbar_round);

}

}

Step 2:
Paste Following Code into xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical" >


    <ProgressBar
        android:id="@+id/progressbar_round"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_margin="5dip"
        android:indeterminateDrawable="@drawable/my_progress_indeterminate" />

</RelativeLayout>

Now Create a folder in res folder named as drawable

Step 3:
Create an xml file named as my_progress_indeterminate and paste following code into it

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/loadingicon"
    android:pivotX="50%"
    android:pivotY="50%" />

and Paste Following code into it Search any png image from image and paste it into hdpi,mdpi,ldpi,xhdpi,xxhdpi folders respectively



No comments:

Post a Comment