This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ViewAnimationController (also referred to as KAnimationController) is an Android library that provides a fluent API for creating and managing view animations. The library simplifies complex animation sequences by providing a declarative, chainable interface for positioning, transforming, and animating Android views.
This is a multi-module Android project with two main modules:
- kanimationcontroller/: The core library module containing all animation logic
- example/: Demo application showcasing library usage
- Min SDK: 15
- Target SDK: 25
- Compile SDK: 25
- Build Tools: 25.0.1
- Android Gradle Plugin: 2.3.0
This project recently migrated from JCenter to Maven Central. The root build.gradle now uses:
google()- for Android dependenciesmavenCentral()- for other dependencies
# Build the entire project
./gradlew build
# Build only the library module
./gradlew :kanimationcontroller:build
# Build the example app
./gradlew :example:build
# Install example app to connected device
./gradlew :example:installDebug
# Run tests
./gradlew test
# Run instrumented tests (requires connected device/emulator)
./gradlew connectedAndroidTest
# Clean build artifacts
./gradlew cleanThe library uses a fluent builder pattern with three main components:
-
BaseAnimationObject (
BaseAnimationObject.java)- Primary API for defining animations on Android Views
- Wraps a View and accumulates animation instructions via method chaining
- Stores animation operations as a list of
IAnimateSetobjects - Each method (e.g.,
scaleX(),moveToCenterHorizontal()) adds anIAnimateSetto the internal list - Animations are executed when
start()orstartDelay()is called
-
IAnimateSet Interface (
IAnimateSet.java)- Contract for individual animation operations
- Each concrete implementation represents a specific animation type (e.g.,
ScaleX,TransY,Alpha,Width,Height) animateView(View)applies the animation to the target viewgetValue()/setValue()allow querying and modifying animation values
-
AnimationQueue (
AnimationQueue.java)- Orchestrates multiple
BaseAnimationObjectinstances - Two execution modes:
startByQueue(): Animations play sequentially, one after anotherstartTogether(): All animations play simultaneously
- Each queue item can have an individual delay
- Provides callbacks via
AnimatedCallbackinterface:finished(): Called when entire queue completeseachQueueFinished(BaseAnimationObject): Called after each individual animation
- Orchestrates multiple
The library provides concrete implementations of IAnimateSet for:
- Position:
X,Y,TransX,TransY,TransXBy,TransYBy - Scale:
ScaleX,ScaleY - Rotation:
RotationX,RotationY,RotationXBy,RotationYBy - Dimensions:
Width,Height - Visibility:
Alpha - Utility:
Reset,Pos
BaseAnimationObject includes relative positioning methods that calculate coordinates based on other animation objects:
- Alignment:
moveToCenterHorizontal(),moveToCenterVertical(),goToLeft(),goToRight(),goToTop(),goToBottom() - Stacking:
stackToLeftOf(),stackToRightOf(),stackToTopOf(),stackToBottomOf() - Margins:
marginLeft(),marginRight(),marginTop(),marginBottom()
These methods account for scaled dimensions when calculating positions, making it easier to create responsive layouts.
The README notes that RelativeLayout is "friendly" with KAnimationController, suggesting this library works best when animating views within RelativeLayout containers.
- The library uses Android's built-in
View.animate()ViewPropertyAnimator under the hood - Duration is set via
setDuration()and applies to the entire animation chain - Custom animations can be added via
addCustomAnimation(IAnimateSet) - The
newAnimate()method creates a freshBaseAnimationObjectfor the same view, clearing previous animations