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 Center Vertically",
color = Color.White)},
backgroundColor = Color(0xFF58427C)) },
content = {MainContent()},
backgroundColor = Color(0xFFEDEAE0)
)
}
@Composable
fun MainContent(){
Row(
modifier = Modifier
.padding(12.dp)
.background(Color(0xFFFFA6C9))
.fillMaxWidth()
.height(250.dp)
.wrapContentSize(align = Alignment.CenterStart)
.padding(16.dp)
) {
Text(
text = "Center Vertically",
style = MaterialTheme.typography.h5
)
}
}
@Preview
@Composable
fun ComposablePreview(){
//GetScaffold()
}
}
- jetpack compose - Row onClick
- jetpack compose - Row weight
- jetpack compose - Column weight
- jetpack compose - Row align end
- jetpack compose - Snackbar host state
- jetpack compose - Scaffold Snackbar host
- jetpack compose - How to use AndroidView
- jetpack compose - How to update AndroidView
- jetpack compose - AndroidView click event
- jetpack compose - AndroidView modifier
- jetpack compose - How to use bottom navigation
- jetpack compose - How to use navigation controller
- jetpack compose - Navigate with argument
- jetpack compose - Navigation multiple arguments
- jetpack compose - Navigation arguments data type