shimmer
fun PlaceholderHighlight.Companion.shimmer(highlightColor: Color, animationSpec: InfiniteRepeatableSpec<Float> = PlaceholderDefaults.shimmerAnimationSpec, @FloatRange(from = 0.0, to = 1.0) progressForMaxAlpha: Float = 0.6f): PlaceholderHighlight(source)
Creates a PlaceholderHighlight which 'shimmers', using the given highlightColor.
The highlight starts at the top-start, and then grows to the bottom-end during the animation. During that time it is also faded in, from 0f..progressForMaxAlpha, and then faded out from progressForMaxAlpha..1f.
Parameters
highlightColor
the color of the highlight 'shimmer'.
animationSpec
the AnimationSpec to configure the animation.
progressForMaxAlpha
The progress where the shimmer should be at it's peak opacity. Defaults to 0.6f.
Samples
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.fade
import io.github.fornewid.placeholder.foundation.placeholder
import io.github.fornewid.placeholder.foundation.shimmer
fun main() {
//sampleStart
Text(
text = "Content to display after content has loaded",
modifier = Modifier
.padding(16.dp)
.placeholder(
visible = true,
color = Color.Gray,
// optional, defaults to RectangleShape
shape = RoundedCornerShape(4.dp),
highlight = PlaceholderHighlight.shimmer(
highlightColor = Color.White,
),
),
)
//sampleEnd
}