MainActivity.kt
package com.cfsuman.jetpackcompose
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
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 {
GetScaffold()
}
}
@Composable
fun GetScaffold(){
Scaffold(
topBar = {TopAppBar(
title = {Text(
"Compose - Row Background",
color = Color.White)},
backgroundColor = Color(0xFF58427C)) },
content = {MainContent()},
backgroundColor = Color(0xFFEDEAE0)
)
}
@Composable
fun MainContent(){
Column(
modifier = Modifier
.fillMaxSize()
.padding(8.dp),
verticalArrangement = Arrangement.SpaceEvenly
) {
Row(
modifier = Modifier
.padding(12.dp)
.background(Color(0xFF89CFF0))
.fillMaxSize()
.weight(1f)
.wrapContentSize(align = Alignment.Center)
) {
Text(
text = "Row Background",
style = MaterialTheme.typography.h5
)
}
Row(
modifier = Modifier
.padding(12.dp)
.background(
Brush.linearGradient(
listOf(
Color(0xFFFF7E00),
Color(0xFF8DB600),
Color(0xFF9966CC)
)
)
)
.fillMaxSize()
.weight(1f)
.wrapContentSize(align = Alignment.Center)
) {
Text(
text = "Gradient Background",
style = MaterialTheme.typography.h5
)
}
}
}
@Preview
@Composable
fun ComposablePreview(){
//GetScaffold()
}
}
- jetpack compose - Row onClick
- jetpack compose - Row weight
- jetpack compose - Row gravity
- jetpack compose - Row space between
- jetpack compose - Row alignment
- jetpack compose - Row overflow
- jetpack compose - Box gradient background color
- jetpack compose - Box rounded corners shape
- jetpack compose - Box content alignment
- jetpack compose - Card corner radius
- jetpack compose - Card shadow
- jetpack compose - Card border
- jetpack compose - Card alignment
- jetpack compose - Card clickable
- jetpack compose - ModalDrawer example