#EndlessMovingView
A handy view that support endless moving a drawable(image, xml drawable), or a custom figure recorded in a Path.
An endless moving view is a period graph, it repeat its single period to fill the view, and shifting towards the direction with the speed configured.
repositories {
jcenter()
}
dependencies {
compile 'com.github.piasy:endlessmovingview:${latest version}'
}
- Usage
- customization + movingDir: left/right/up/down + movingSpeed: pixels per frame, in 60 fps + paintColor/paintStyle(fill, stroke, fill_and_stroke): used for EndlessMovingPathView to config the Paint used to draw the path + singlePeriodBitmap: used for EndlessMovingBitmapView, set the single period graph + stopWhenLoseFocus: whether stop moving when window lose focus + autoStart: whether start moving after inflated
- EndlessMovingBitmapView
Just set the moving direction & speed, and set one single period graph for the total graph in xml is enough
<com.github.piasy.handywidgets.endlessmovingview.EndlessMovingBitmapView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mEndlessMovingViewLeft"
android:background="@android:color/holo_green_light"
android:layout_width="100dp"
android:layout_height="100dp"
app:movingDir="left"
app:movingSpeed="2"
app:paintColor="@android:color/holo_blue_bright"
app:paintStyle="fill"
app:singlePeriodBitmap="@drawable/iv_loading"
app:stopWhenLoseFocus="false"
app:autoStart="true"
/>
-
EndlessMovingPathView
ExcendEndlessMovingPathView
and override itsgetSinglePeriodGraphWidth()
,getSinglePeriodGraphHeight()
,drawPath(Path path, @EndlessMovingView.MovingDir int movingDir, int start, int minX, int maxX, int minY, int maxY)
method, to set single period graph width, height, and draw one single graph in thePath
object.
Examples is xml, code. -
Full example could be found at the app module
-
Todo
-
Correct start/stop control
-
EndlessMovingPathView -
Screenshot -
Performance opt
-
Acknowledgement
-
Inspired by naman14's WashingMachineView
-
Gififying with gifify