MainActivity.kt
package com.cfsuman.jetpackcompose
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {GetScaffold()}
}
@Composable
fun GetScaffold() {
Scaffold(
topBar = {TopAppBar(
title = {Text(text = "Compose - Screen Width Height In Dp")},
backgroundColor = Color(0xFF5F9EA0),
)},
content = { MainContent() },
backgroundColor = Color(0xFFA7D8DE)
)
}
@Composable
fun MainContent() {
val configuration = LocalConfiguration.current
val screenWidth = configuration.screenWidthDp
val screenHeight = configuration.screenHeightDp
Box(Modifier.fillMaxSize().wrapContentSize(Alignment.Center)) {
Text(
text = "Screen Width : $screenWidth Dp" +
"\nScreen Height: $screenHeight Dp",
fontSize = 27.sp,
textAlign = TextAlign.Center
)
}
}
}
- jetpack compose - Get screen layout direction
- jetpack compose - How to change StatusBar color
- jetpack compose - How to change NavigationBar color
- jetpack compose - How to change SystemBars color
- jetpack compose - Kotlinx serialization decode josn element
- jetpack compose - How to use kotlin flow
- jetpack compose - Random number flow
- jetpack compose - flowOf flow builder
- jetpack compose - Convert list to flow
- jetpack compose - Count down flow
- jetpack compose - Count up flow by ViewModel
- jetpack compose flow - Room add remove update
- jetpack compose flow - Room implement search
- jetpack compose - Icon from vector resource
- jetpack compose - IconButton from vector resource