Change the size of box in Jetpack Compose doesnt work

Viewed 31

i am trying to specify the size for my box composable but for some reason it just fills out the whole screen

@Composable
fun InfoBox() {
    Box(modifier = Modifier
        .background(Color.Blue)
        .size(width = 300.dp, height = 370.dp)
        .border(BorderStroke(2.dp, Color.Red))) {
    
    }
}
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            BDControlTheme(darkTheme = true) {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    //BackgroundElements()
                    //ModiButtons()
                    InfoBox()

                    //PostView()

                }
            }
        }
    }
}

What am i missing? It seems that i am using .fillMaxSize but i never use this and just use .size(width = ...,height=...) to set my box size?

0 Answers
Related