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.layout.Column
import androidx.compose.material.*
import androidx.compose.runtime.*
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 {
MainContent()
}
}
@Composable
fun MainContent(){
Column(
Modifier
.background(Color(0xFFEDEAE0))
.fillMaxSize()
.padding(32.dp),
verticalArrangement = Arrangement.spacedBy(24.dp)
) {
Button(
onClick = {
// do something here
},
colors = ButtonDefaults.buttonColors(
backgroundColor = Color(0xFFFF2400),
contentColor = Color(0xFFFFF5EE),
disabledBackgroundColor = Color(0xFF59260B),
disabledContentColor = Color(0xFF8A795D)
),
enabled = true
) {
Text(text = "Verify Me")
}
Button(
onClick = {
// do something here
},
colors = ButtonDefaults.buttonColors(
backgroundColor = Color(0xFFFF2400),
contentColor = Color(0xFFFFF5EE),
disabledBackgroundColor = Color(0xFF59260B),
disabledContentColor = Color(0xFF8A795D)
),
enabled = false
) {
Text(text = "Verify Me")
}
TextButton(
onClick = {
// do something here
},
colors = ButtonDefaults.textButtonColors(
backgroundColor = Color(0xFFFAD6A5),
contentColor = Color(0xFFA83731),
disabledContentColor = Color(0xFFD2B48C)
),
enabled = true
) {
Text(text = "Share Me")
}
OutlinedButton(
onClick = {
// do something here
},
colors = ButtonDefaults.outlinedButtonColors(
backgroundColor = Color(0xFF4C2882),
contentColor = Color(0xFFECEBBD),
disabledContentColor = Color(0xFF914E75)
),
enabled = true
) {
Text(text = "Share Location")
}
}
}
@Preview
@Composable
fun ComposablePreview(){
//MainContent()
}
}
- jetpack compose - Canvas withTransform
- jetpack compose - Double tap listener
- jetpack compose - Long press listener
- jetpack compose - Tap listener
- jetpack compose - Press listener
- jetpack compose - Column vertical scrolling
- jetpack compose - Dragging
- jetpack compose - Multiple draggable objects
- jetpack compose - Swiping
- jetpack compose - Panning zooming rotating
- jetpack compose - Weight modifier
- jetpack compose - Outlined Button
- jetpack compose - TextButton
- jetpack compose - Button with icon
- jetpack compose - Button rounded corners