A simple library to show a loader around the edges of a materail chip
Usage
put in root build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
in module build.gradle
implementation 'com.github.AbhinavChauhan97:LoaderChip:1.0.4'
Simply put in your layout file
<com.abhinav.chouhan.loaderchip.LoaderChip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
by deault a red loading line will show up , you can customize with following attributes
attribute | format | desciption |
---|---|---|
loaderColor | color | give a desired color to loader line |
loaderWidth | dimension | give desired with to loading line |
lapDuration | integer | give desired duration in millis for a complete rotation of loader line around the chip |
loadOnClick | boolean | indicates whether or not you want to start the laoder on the click of the chip , defaut value is true |
loaderColorStart/loaderColorEnd | color | these attributes falls in one column because there effect is only visible if both of them are present they are used to draw loading line in a gradient color , where loaderColorStart gives the start color and loaderColorEnd gives the end color of the gradient , when these attributes are present loaderColor attributes is ignored if present , if only one of them is present loaderColor is used. |
reverseEffect | boolean | indicates whether or not loader should go back and forth |
loadingText | String | optional text to show while loading |
loadingTextColor | color | text color to show while loading |
loaderStyle | enum | use to provide a loading style possible values bounce , accelerate , decelerate , accelerateThenDecelerate (default) , linear , overshoot , fastOutSlowIn |
Default Loader
Gradient Loader (Use both loaderColorStart and loaderColorEnd attributes for gradient loader of those two colors)
Loader with width = 4dp and lapduration = 4000 milliseconds
Loader with overshoot
loaderStyle
Loader with bounce
loaderStyle
Loaders with reverseEffect
enabled and with vairous corner radius
xml file of above Screen
<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.abhinav.chouhan.loaderchip.LoaderChip
android:id="@+id/loaderChip3"
android:layout_width="200dp"
android:layout_height="60dp"
android:text="Clicked Me !"
app:lapDuration="2000"
app:loaderWidth="5dp"
app:loaderStyle="bounce"
app:chipCornerRadius="5dp"
app:reverseEffect="true"
app:layout_constraintVertical_bias="0.7"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.abhinav.chouhan.loaderchip.LoaderChip
android:id="@+id/loaderChip2"
android:layout_width="200dp"
android:layout_height="60dp"
android:text="Clicked Me !"
app:lapDuration="3000"
app:loaderWidth="8dp"
app:loaderStyle="overshoot"
app:reverseEffect="true"
app:loaderColor="@android:color/holo_blue_bright"
app:loaderColorStart="@android:color/holo_blue_bright"
app:loaderColorEnd="@android:color/holo_red_light"
app:layout_constraintVertical_bias="0.1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.abhinav.chouhan.loaderchip.LoaderChip
android:id="@+id/loaderChip"
android:layout_width="200dp"
android:layout_height="60dp"
android:text="Clicked Me !"
app:lapDuration="2000"
app:loaderWidth="3dp"
app:reverseEffect="true"
app:chipCornerRadius="15dp"
app:layout_constraintVertical_bias="0.4"
app:loaderColor="@android:color/holo_blue_bright"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Version 1.0.5 ( 10-july-2021)
give optional text whilte loading , attributes loadingText
, loadingTextColor
are added
Contributions thanks to cheticamp from stackoverflow for fixing this major bug.