Min. SDK: 19 Kotlin
Full example you can see in sample app. You can download an APK of the sample app
What's done
- GradientView component
- GradientTextView component
- Gradient vertical/horizontal orientation
- Animation support for GradientView
- Animation support for GradientTextView
- Optional animation loop
- Optional animation start after component creation
- Animation attributes
- Round corners support and attributes for GradientView
TODO
- Angle cupport for gradient orientation
- Gradient orientation angle animation
- Gradient overlay for all type of views
- Optimization for animation of GradientTextView
- Improve animation loop realization
GradientView, GradientTextView attributes
- gradientOrientation
- baseColors
- startColorsPositions
- endColorsPositions
- animationOnStart
- animationStepDuration
- animationLoop
- topLeftCorner (only for GradientView)
- topRightCorner (only for GradientView)
- bottomLeftCorner (only for GradientView)
- bottomRightCorner (only for GradientView)
- Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency
dependencies {
implementation 'com.github.GreyLabsDev:GradientComponents:0.5.0'
}
GradientView
<com.greylabs.gradientcomponents.component.GradientView
android:layout_width="match_parent"
android:layout_height="240dp"
app:gradientOrientation="horizontal"
app:baseColors="#91276C, #0F3368"
app:startColorsPositions="0, 0.66"
app:endColorsPositions="0.5, 0.99"
app:animationStepDuration="2000"
app:animationLoop="true"
app:animationOnStart="true"
app:topLeftCorner="32dp"
app:bottomRightCorner="32dp"
/>
GradientTextView
val gradientText = GradientTextView(requireContext())
gradientText.apply {
setOrientation(gradientOrientation)
addGradientColor("#FFFFFF")
addGradientColor("#91276C")
addGradientPosition(firstColorPos, secondColorPos)
addGradientPosition(0.9f, 1f)
setAnimationOnStart(isAnimationEnabled)
setLoopAnimation(isAnimationLoop)
setAnimationStepDuration(900L)
text = "Some text"
initView()
}