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.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.*
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.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 - Box Rounded Corners",
color = Color.White)},
backgroundColor = Color(0xFF58427C)) },
content = {MainContent()},
backgroundColor = Color(0xFFEDEAE0)
)
}
@Composable
fun MainContent(){
Column(
modifier = Modifier
.fillMaxSize(),
verticalArrangement = Arrangement.SpaceEvenly,
horizontalAlignment = Alignment.CenterHorizontally
){
Box(
Modifier
.padding(12.dp)
.fillMaxWidth()
.height(150.dp)
.clip(RoundedCornerShape(12.dp))
.background(Color(0xFFB9D9EB)),
contentAlignment = Alignment.Center
){
Text(text = "Rounded Corners 12 DP")
}
Box(
Modifier
.padding(12.dp)
.fillMaxWidth()
.height(150.dp)
.clip(RoundedCornerShape(topEnd = 20.dp))
.background(Color(0xFFC2B280)),
contentAlignment = Alignment.Center
){
Text(text = "Rounded Corners Top End Only 20 DP")
}
Box(
Modifier
.padding(12.dp)
.width(150.dp)
.height(150.dp)
.clip(CircleShape)
.background(Color(0xFFE5AA70)),
contentAlignment = Alignment.Center
){
Text(text = "Circle Shape")
}
}
}
@Preview
@Composable
fun ComposablePreview(){
//GetScaffold()
}
}
- jetpack compose - Column weight
- jetpack compose - Row center vertically
- jetpack compose - Row align end
- jetpack compose - Row space between
- jetpack compose - Row alignment
- jetpack compose - Row overflow
- jetpack compose - Column align bottom
- jetpack compose - Box center alignment
- jetpack compose - Box gradient background color
- jetpack compose - Box content alignment
- jetpack compose - How to change StatusBar color
- jetpack compose - How to change NavigationBar color
- jetpack compose - How to change SystemBars color
- jetpack compose - Icon from vector resource
- jetpack compose - IconButton from vector resource