- Wrap your layout
<com.github.tehras.loadingskeleton.LoadingSkeleton
android:id="@+id/skeleton_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</com.github.tehras.loadingskeleton.LoadingSkeleton>
- Start and Stop
//use as a normal layout
val loadingSkeleton = findViewById(R.id.skeleton_layout) as LoadingSkeleton
//start loading layout
loadingSkeleton.start()
//stop loading layout
loadingSkeleton.stop()
- Setting custom actions
Java:
//Set your own Skeleton View Converter
loadingSkeleton
.skeletonViewConverter(new LoadingSkeletonViewConverter.Builder()
.color(R.color.colorPrimary) //set color
.shimmer(true) //shimmer, true/false
.cornerRadius(16f) //corner radius
.gradient(true) //gradient, true/false
.addConvert(YourLoadingSkeletonViewConverter1()) //add your own custom conver
.addConvert(YourLoadingSkeletonViewConverter2()) //adding converter ovverides default ones
.build()) //build, and you're done
Kotlin:
loadingSkeleton
.skeletonViewConverter(LoadingSkeletonViewConverter.Builder()
.color(R.color.colorPrimary) //set color
.shimmer(true) //shimmer, true/false
.gradient(true) //gradient, true/false
.cornerRadius(16.toFloat()) //corner radius
.addConvert(YourLoadingSkeletonViewConverter1()) //add your own custom conver
.addConvert(YourLoadingSkeletonViewConverter2()) //adding converter ovverides default ones
.build()) //build, and you're done
- Extend
LoadingSkeletonViewStreamer<T : View>
- Implement
public void convert(Context c, T v, Options options)
||fun convert(c: Context, v: T, options: Options)
- Called when.start()
is called for EVERY view - Implement
public void revert(Context c, T v)
||fun revert(c: Context, v: T)
- Called when.stop
is called for EVERY view - There are optional
public void start(){}
||fun start(){}
andpublic void stop(){}
fun stop(){}
fields that are called only once at start and stop
(Just take a look at the DefaultTextViewStreamer or DefaultImageViewStreamer for examples)
compile 'com.github.tehras:loading-skeleton:0.2.9'
<dependency>
<groupId>com.github.tehras</groupId>
<artifactId>loading-skeleton</artifactId>
<version>0.2.9</version>
<type>pom</type>
</dependency>