MainActivity.kt
package com.cfsuman.jetpackcompose
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.padding
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.Composable
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(){
ExtendedFloatingActionButton(
text = { Text("Like Us")},
onClick = {
Toast.makeText(
this,
"Clicked",
Toast.LENGTH_SHORT
).show()
},
icon = { Icon(
Icons.Filled.Favorite,
"Localized description",
tint = Color(0xFFCCFF00)
)},
elevation = FloatingActionButtonDefaults.elevation(8.dp),
backgroundColor = Color(0xFFFF9933),
contentColor = Color.White,
modifier = Modifier.padding(16.dp)
)
}
@Preview
@Composable
fun ComposablePreview(){
//MainContent()
}
}
- jetpack compose - How to use Text
- jetpack compose - ClickableText example
- jetpack compose - How to use Card
- jetpack compose - How to use Checkbox
- jetpack compose - How to use RadioButton
- jetpack compose - Radio group example
- jetpack compose - How to use Floating Action Button
- jetpack compose - How to use DropdownMenu
- jetpack compose - How to use IconButton
- jetpack compose - How to use IconToggleButton
- jetpack compose - How to use Column layout
- jetpack compose - How to use Row layout
- jetpack compose - Box layout example
- jetpack compose - How to use AlertDialog
- jetpack compose - Row scrolling