MainActivity.kt
package com.cfsuman.jetpackcompose
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MainContent()
}
}
@Composable
fun MainContent(){
Card(
Modifier
.fillMaxWidth(.95F)
.padding(15.dp),
backgroundColor = Color.Yellow,
elevation = 8.dp,
shape = MaterialTheme.shapes.medium,
border = BorderStroke(3.dp, Color.Red),
) {
Text(
text = "I am a Card.",
fontSize = 35.sp,
fontStyle = FontStyle.Normal,
fontWeight = FontWeight.Bold,
fontFamily = FontFamily.SansSerif,
modifier = Modifier
.padding(25.dp),
textAlign = TextAlign.Center,
color = Color.Blue
)
}
}
@Preview
@Composable
fun ComposablePreview(){
//MainContent()
}
}
- jetpack compose - How to use Text
- jetpack compose - ClickableText example
- jetpack compose - How to use Button
- jetpack compose - How to use Checkbox
- jetpack compose - How to use RadioButton
- jetpack compose - Cut corner shape example
- jetpack compose - Image from drawable
- jetpack compose - Image from vector
- jetpack compose - Image from bitmap
- jetpack compose - Circular image example
- jetpack compose - Accessing string resources
- jetpack compose - String resource positional formatting
- jetpack compose - String resource plurals
- jetpack compose - Get dimension resource
- jetpack compose - Get color resource