HourglassView

This is a custom view effect that mimics an hourglass

rendering

(PS: GIF with dot card)

Usage:

Build. Gradle adds dependencies

Dependencies {the compile 'com. Yzy: HourglassView: 1.0.0'}Copy the code





Related custom attributes

xml:

<com.yzy.library.HourglassView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/HourglassView" Android :layout_width="wrap_content" // Set the height, Android :layout_height="100dp" APP :hv_sand_color="@color/colorAccent" app:hv_leftAndRight_color="#00C4FF" App :hv_topAndBottom_color="#844F01" app:hv_flat="7.5" app:hv_duration="6000" app:hv_auto="false" />Copy the code

Code sets

/ / animation time hourglassView setDuration (6000); / / border color hourglassView. SetLeftAndRightColor (color); / / up and down the lid color hourglassView setTopAndBottomColor (color); / / sand color hourglassView setSandColor (color); // Default flatness 7.5f Recommendation 3-10 hourglassView.setfalt (float); // Start the animation hourglassView.start(); // End the animation hourglassView.end(); //minSDK>=19 hourglassView.pause(); hourglassView.resume(); / / state monitor hourglassView. SetStateListener (new hourglassView. OnStateListener () {@ Override public void onStart () {} @Override public void onEnd() { } });Copy the code