Kotlin (Android) Result Progress Bar Design [NEW] – Coding Shiksha

Kotlin (Android) Result Progress Bar Design [NEW] – Coding Shiksha

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

READ  How to make Smart Custom Alert Dialog in Kotlin - Coding Shiksha

 

Demo

 

 

 

 

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>

 

READ  Kotlin Google Maps AutocompleteTextView Location Example - Coding Shiksha

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

Close Menu

Indian Desi Tools - Ultimate Tools Website

Demo Description


This will close in 20 seconds