MainActivity.java
====================
package com.sam.web.progressbar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
public class MainActivity extends AppCompatActivity {
int progress;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove the title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove the notification bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
progressBar=(ProgressBar) findViewById(R.id.progressBarId);
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
doWork();
}
});
thread.start();
}
public void doWork(){
for(progress=20;progress<=100; progress=progress+20){
try {
Thread.sleep(1000);
progressBar.setProgress(progress);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
====================================================================================
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"
tools:context="com.sam.web.progressbar.MainActivity">
<ProgressBar
android:progressBackgroundTint="#94ff22"
android:progressTint="@color/colorAccent"
android:id="@+id/progressBarId"
android:layout_margin="20dp"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
=====================================================================================
style.xml
============
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.