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.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 Alignment",
color = Color.White)},
backgroundColor = Color(0xFF58427C)) },
content = {MainContent()},
backgroundColor = Color(0xFFEDEAE0)
)
}
@Composable
fun MainContent(){
Column(
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
verticalArrangement = Arrangement.SpaceEvenly
) {
Row(
modifier = Modifier
.height(150.dp)
.fillMaxWidth()
.background(Color(0xFFC0E8D5))
.wrapContentSize(Alignment.TopEnd)
.padding(12.dp)
) {
Text(
text = "Alignment End",
Modifier.background(Color(0xFFF19CBB))
.padding(12.dp)
)
}
Row(
modifier = Modifier
.height(150.dp)
.fillMaxWidth()
.background(Color(0xFFCD9575))
.wrapContentSize(Alignment.BottomCenter)
.padding(12.dp)
) {
Text(
text = "Alignment Bottom Center",
Modifier.background(Color(0xFF89CFF0))
.padding(12.dp)
)
}
Row(
modifier = Modifier
.height(150.dp)
.fillMaxWidth()
.background(Color(0xFF8DB600))
.wrapContentSize(Alignment.Center)
.padding(12.dp)
) {
Text(
text = "Alignment Center",
Modifier.background(Color(0xFFF0FFFF))
.padding(12.dp)
)
}
}
}
@Preview
@Composable
fun ComposablePreview(){
//GetScaffold()
}
}
- jetpack compose - Row gravity
- jetpack compose - Row background
- jetpack compose - Row space between
- jetpack compose - Row overflow
- jetpack compose - How to change StatusBar color
- jetpack compose - How to change NavigationBar color
- jetpack compose - How to change SystemBars color
- jetpack compose - How to hide system bars
- jetpack compose - Detect screen orientation change
- jetpack compose ktor - How to get api data
- jetpack compose ktor - How to post data
- jetpack compose - Kotlinx serialization pretty print
- jetpack compose - Kotlinx serialization lenient parsing
- jetpack compose - Kotlinx serialization not encode null values
- jetpack compose - Kotlinx serialization encode to string