MainActivity.kt
package com.cfsuman.jetpackcompose
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.imageResource
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(){
Column(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFFFEFEFA))
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(32.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
bitmap = ImageBitmap
.imageResource(
id = R.drawable.flower3
),
contentDescription ="Localized description",
Modifier
.clip(CircleShape)
.background(Color.Yellow)
.size(300.dp),
contentScale = ContentScale.Crop
)
Image(
bitmap = ImageBitmap
.imageResource(
id = R.drawable.flower3
),
contentDescription ="Localized description",
Modifier
.clip(CircleShape)
.background(Color.Yellow)
.fillMaxWidth()
.height(150.dp),
contentScale = ContentScale.Crop
)
}
}
@Preview
@Composable
fun ComposablePreview(){
//MainContent()
}
}
- jetpack compose - Cut corner shape example
- jetpack compose - Image from drawable
- jetpack compose - Image from vector
- jetpack compose - Image from bitmap
- jetpack compose - LazyColumn alternate item color
- jetpack compose - LazyColumn sticky header
- jetpack compose - Animate content size
- jetpack compose - FadeIn FadeOut animation
- jetpack compose - Tween animation
- jetpack compose - Keyframes animation
- jetpack compose - AnimateContentSize customization
- jetpack compose - Spring animation
- jetpack compose - Column scrollable
- jetpack compose - Row spacing
- jetpack compose - Row scrolling