MainActivity.kt
package com.cfsuman.jetpackcompose
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.animation.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MainContent()
}
}
@Composable
fun MainContent(){
val infiniteTransition = rememberInfiniteTransition()
val color = infiniteTransition.animateColor(
initialValue = Color(0xFF8DB600),
targetValue = Color(0xFFE30022),
animationSpec = infiniteRepeatable(
animation = tween(
durationMillis = 5000,
easing = LinearEasing
),
repeatMode = RepeatMode.Reverse
)
)
Column(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFFE3DAC9))
.padding(16.dp),
verticalArrangement = Arrangement.Center
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(250.dp)
.background(color.value)
)
}
}
@Preview
@Composable
fun ComposablePreview(){
//MainContent()
}
}
- jetpack compose - Animate content size
- jetpack compose - FadeIn FadeOut animation
- jetpack compose - ExpandIn ShrinkOut animation
- jetpack compose - SlideIn SlideOut animation
- jetpack compose - Canvas withTransform
- jetpack compose - Canvas inset
- jetpack compose - Draw arc on canvas
- jetpack compose - Double tap listener
- jetpack compose - Long press listener
- jetpack compose - Tap listener
- jetpack compose - Dragging
- jetpack compose - Multiple draggable objects
- jetpack compose - Swiping
- jetpack compose - Outlined Button
- jetpack compose - TextButton