Depict durations in Android apps in a beautiful way

Overview

Duration View

Duration View allows you to create views to depict durations of time.

For example, if you wish to display a duration split into Days, Hours, Mins and Secs, you just need to set the values and DurationView will do the rendering for you.

alt text . . . . . alt text

Sample App

Download the Demo app on Google Play Store:

Get it on Google Play

Installation

Gradle

Add JitPack in your root build.gradle at the end of repositories:

allprojects {
	repositories {
        ...
		maven { url 'https://jitpack.io' }
    }
}

Add it as a dependency in your app's build.gradle file

dependencies {
    implementation 'com.github.rayzone107:DurationView:1.00'
}

How to use

Add a DurationView to your XML layout

Below are the default values for all the properties

<com.rachitgoyal.durationitem.DurationView
        android:id="@+id/duration_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        
        app:dv_days="0"                         \\ Integer Value for 1st Numerical Section
        app:dv_hours="0"                        \\ Integer Value for 2st Numerical Section
        app:dv_mins="0"                         \\ Integer Value for 3rd Numerical Section
        app:dv_secs="0"                         \\ Integer Value for 4th Numerical Section
        app:dv_number_text_size="12sp"          \\ Text Size of above values

        app:dv_show_days="true"                 \\ Whether to show 1st Section or not
        app:dv_show_hours="true"                \\ Whether to show 2nd Section or not
        app:dv_show_mins="true"                 \\ Whether to show 3rd Section or not
        app:dv_show_secs="true"                 \\ Whether to show 4th Section or not

        app:dv_show_labels="true"               \\ Whether to show labels or not
        app:dv_days_label="DAYS"                \\ String label for 1st section
        app:dv_hours_label="HOURS"              \\ String label for 2nd section
        app:dv_mins_label="MINS"                \\ String label for 3rd section
        app:dv_secs_label="SECS"                \\ String label for 4th section
        app:dv_label_position="bottom"          \\ Can be 'top' or 'bottom'
        app:dv_label_text_size="18sp"           \\ Label text size
        app:dv_label_vertical_padding="6dp"     \\ Padding between label and numbers

        app:dv_text_color="#000000"             \\ Color that will be applied to all text, if below values are not set
        app:dv_number_color="#000000"           \\ Color that will be all numbers, if not individually set
        app:dv_label_color="#000000"            \\ Color that will be all labels, if not individually set
                                           
        app:dv_days_color="#000000"             \\ Days Text Color, will override text_color and number_color
        app:dv_hours_color="#000000"            \\ Hours Text Color, will override text_color and number_color
        app:dv_mins_color="#000000"             \\ Mins Text Color, will override text_color and number_color
        app:dv_secs_color="#000000"             \\ Secs Text Color, will override text_color and number_color

        app:dv_days_label_color="#000000"       \\ Days Label Text Color, will override text_color and label_color
        app:dv_hours_label_color="#000000"      \\ Hours Label Text Color, will override text_color and label_color
        app:dv_mins_label_color="#000000"       \\ Mins Label Text Color, will override text_color and label_color
        app:dv_secs_label_color="#000000"       \\ Secs Label Text Color, will override text_color and label_color

        app:dv_show_dividers="false"            \\ Whether to show dividers between views
        app:dv_divider_color="#000000"          \\ Divider color
        app:dv_divider_top_bottom_margin="4dp"  \\ Divider top and bottom margin from view edges
        app:dv_divider_width="2dp" />           \\ Divider width

Note that "wrap_content" might not function properly. wrap_content and match_parent might work the same way. Either set absolute dimensions in dp, or set match_parent with limited available area (within a ViewGroup).

These values can also be set programatically.

        DurationView durationView = findViewById(R.id.duration_view);
        
        durationView.setDays(rnd.nextInt(100));
        durationView.setHours(rnd.nextInt(24));
        durationView.setMins(rnd.nextInt(60));
        durationView.setSecs(rnd.nextInt(60));
        durationView.setDaysColor(Color.BLACK);
        durationView.setHoursColor(Color.BLACK);
        durationView.setMinsColor(Color.BLACK);
        durationView.setSecsColor(Color.BLACK);
        durationView.setDaysLabelColor(Color.BLACK);
        durationView.setHoursLabelColor(Color.BLACK);
        durationView.setMinsLabelColor(Color.BLACK);
        durationView.setSecsLabelColor(Color.BLACK);
        
        durationView.setLabelTextSize(10f);
        durationView.setNumberTextSize(18f);
        
        durationView.setShowDividers(true);
        durationView.setDividersColor(Color.BLACK);
        durationView.setDividersMargin(2f);
        durationView.setDividersWidth(2f);

Contribution

Any kind of contribution will be appreciated; feel free to create a pull request or file issues on the issue tracker.

You might also like...
Extension functions over Android's callback-based APIs which allows writing them in a sequential way within coroutines or observe multiple callbacks through kotlin flow.

callback-ktx A lightweight Android library that wraps Android's callback-based APIs into suspending extension functions which allow writing them in a

Display code with syntax highlighting :sparkles: in native way.
Display code with syntax highlighting :sparkles: in native way.

CodeView (Android) CodeView helps to show code content with syntax highlighting in native way. Description CodeView contains 3 core parts to implement

The easiest way to bring validation to your project
The easiest way to bring validation to your project

RxValidationTextInputLayout The easiest way to bring validation to EditText with TextInputLayout. Getting Started Add dependency to your project using

A simple way to handle remote image in Kotlin.
A simple way to handle remote image in Kotlin.

Parrot A kotlin extension to load easily remote images in your ImageView. Install Add to gradle in allprojects maven { url 'https://jitpack.io' } the

:closed_umbrella: An easy way to implement modern permission instructions popup.
:closed_umbrella: An easy way to implement modern permission instructions popup.

Needs An easy way to implement modern permission instructions popup. Needs can be fully customized and showing with animations. Download Gradle Add be

A fragment binding library - the easier, efficient way.

Byda allprojects { repositories { ... maven { url 'https://jitpack.io' } } } dependencies { implementation 'com.github.Codzure:B

Modern Calendar View Supporting Both Hijri and Gregorian Calendars but in highly dynamic way
Modern Calendar View Supporting Both Hijri and Gregorian Calendars but in highly dynamic way

KCalendar-View Modern calendar view supporting both Hijri and Gregorian calendar

kinstall is an easy way to install gradle-based command-line kotlin projects that use the application plugin.

kinstall kinstall is an easy way to install gradle-based command-line kotlin projects that use the application plugin. use First, install kinstall its

AdsManager - Easy way to implement Google Ads

AdsManager Easy way to implement Google Ads Implementaion: https://jitpack.io/#R

Releases(1.00)
A beautiful material calendar with endless scroll, range selection and a lot more!

CrunchyCalendar A light, powerful and easy to use Calendar Widget with a number out of the box features: Infinite vertical scrolling in both direction

CleverPumpkin 483 Dec 25, 2022
EightyTwenty is life planner application with beautiful user interface.

EightyTwenty EightyTwenty is life planner application with beautiful user interface. Version 0.0.1 Add notes Add categories Add notes with image Move

Behzod Halil 3 Jul 15, 2022
An amazing expense tracker app, with great features and beautiful UI. Check it out!

My Expense Tracker Expense tracker app to keep your finances in order. Built entirely in Kotlin using modern architecture components. Build ??️ My Exp

Ken Ali 7 Oct 26, 2022
A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports

A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports 1. What are Jetpack Compose compiler metrics? The Comp

Jaya Surya Thotapalli 116 Jan 3, 2023
:bouquet: An easy way to persist and run code block only as many times as necessary on Android.

Only ?? An easy way to persist and run code block only as many times as necessary on Android. Download Gradle Add below codes to your root build.gradl

Jaewoong Eum 479 Dec 25, 2022
Android Library that provide simpler way to achieve modularity

ToyBricks 中文文档 ToyBricks简介以及原理分析 ToyBricks用户手册 Introduction Android Library that provide simpler way to achieve modularity. Compile System requirement

null 33 Nov 14, 2022
Simple Android Library, that provides easy way to start the Activities with arguments.

Warning: Library is not maintained anymore. If you want to take care of this library, propose it via Pull Request. It needs adjustmensts for newer ver

Marcin Moskała 429 Dec 15, 2022
:bouquet: An easy way to persist and run code block only as many times as necessary on Android.

Only ?? An easy way to persist and run code block only as many times as necessary on Android. Download Gradle Add below codes to your root build.gradl

Jaewoong Eum 468 Apr 14, 2021
:performing_arts: An easy, flexible way to implement veil skeletons and shimmering effect for Android.

AndroidVeil An easy, flexible way to implement veil skeletons and shimmering effect for Android. Download Gradle Add below codes to your root build.gr

Jaewoong Eum 1.2k Dec 28, 2022
A lightweight alternative to Android's ViewModels. The easiest way to retain instances in Activities, Fragments or Composables.

A lightweight alternative to Android's ViewModels. The easiest way to retain instances in Activities, Fragments or Composables.

Marcello Galhardo 264 Dec 27, 2022