Kotlin (Android) Result Progress Bar Design [NEW]

Welcome folks I am back with another block post send this blog post we will be talking about that how to implement a result progress bar into your Android application with kotlin language so we are using a library for it specific library which is designed for including this kind of functionality in your Android application to the library name is result progress bar show the demo of this application is given below so you can check the demo and also the whole source code of this application is also given so please copy paste the source code and also try to extend the source code accordingly to your needs

 

Demo

 

See also  Join 4 Kotlin Android Whatsapp Group Link For Mobile Android Developers in 2021 | Kotlin Whatsapp Group Links For Android Mobile Developers | Whatsapp Group Links For Kotlin Android Programmers

 

 

 

Setup

Add this line to your dependency{} block in app build.gradle file
implementation ‘com.sadwyn.resultprogressbar:resultprogressbar:1.0.0’

Also you need to add mavenLocal() repository to your top gradle file.

 

Example Source Code

 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity">

    <com.sadwyn.resultprogressbar.ResultProgressBar
        android:id="@+id/pb"
        android:layout_width="@dimen/default_progress_bar_height"
        android:layout_height="@dimen/default_progress_bar_width"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:failureDrawable="@drawable/ic_fail"
        app:failureDrawableMargin="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:progressDrawableMargin="20dp"
        app:progressInterpolator="linear"
        app:progressSpeed="normal"
        app:successDrawable="@drawable/ic_success"
        app:successDrawableMargin="30dp">

    </com.sadwyn.resultprogressbar.ResultProgressBar>

    <com.sadwyn.resultprogressbar.ResultProgressBar
        android:id="@+id/pb2"
        android:layout_width="@dimen/default_progress_bar_height"
        android:layout_height="@dimen/default_progress_bar_width"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:changeStateType="alpha"
        app:failureDrawable="@drawable/ic_fail"
        app:failureDrawableMargin="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.098"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:progressDrawableMargin="20dp"
        app:progressInterpolator="linear"
        app:progressSpeed="slow"
        app:successDrawable="@drawable/ic_success"
        app:successDrawableMargin="30dp">

    </com.sadwyn.resultprogressbar.ResultProgressBar>

    <com.sadwyn.resultprogressbar.ResultProgressBar
        android:id="@+id/pb3"
        android:layout_width="@dimen/default_progress_bar_height"
        android:layout_height="@dimen/default_progress_bar_width"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:changeStateType="scale"
        app:failureDrawable="@drawable/ic_fail"
        app:failureDrawableMargin="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.901"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:progressDrawableMargin="20dp"
        app:progressInterpolator="linear"
        app:progressSpeed="fast"
        app:successDrawable="@drawable/ic_success"
        app:successDrawableMargin="30dp">

    </com.sadwyn.resultprogressbar.ResultProgressBar>

    <Button
        android:id="@+id/startBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="36dp"
        android:text="Start"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/successBtn"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent" />

    <Button
        android:id="@+id/successBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="36dp"
        android:text="Success"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/failureBtn"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/startBtn" />

    <Button
        android:id="@+id/failureBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="36dp"
        android:text="Failure"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/successBtn" />


</androidx.constraintlayout.widget.ConstraintLayout>

 

See also  Build a About Screen UI in Android Applications with Kotlin

MainActivity.kt

 

package com.sadwyn.statepb

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.sadwyn.resultprogressbar.ResultProgressBar
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), ResultProgressBar.AnimationListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        startBtn.setOnClickListener { pb.reset(); pb2.reset();pb3.reset() }
        successBtn.setOnClickListener { pb.success(); pb2.success(); pb3.success() }
        failureBtn.setOnClickListener { pb.failure(); pb2.failure(); pb3.failure() }
        pb.listener = this
    }

    override fun onAnimationResult(success: Boolean) {
        Log.i("TAG", "Animation success status is : $success")
    }
}

Leave a Reply