loloof64
11/23/2020, 6:17 PMimport androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.loloof64.chessexercisesorganizer.R
import com.loloof64.chessexercisesorganizer.ui.components.StaticChessBoard
import com.loloof64.chessexercisesorganizer.ui.material.GameScreenTheme
@Composable
fun GameScreen(topLevelNavController: NavController) {
GameScreenTheme {
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
stringResource(id = R.string.game_page),
)
},
navigationIcon = {
IconButton(onClick = {
topLevelNavController.popBackStack()
}) {
Icon(Icons.Filled.ArrowBack)
}
}
)
},
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
StaticChessBoard(modifier = Modifier.preferredSize(300.dp))
}
}
}
}
You can see that I set up Arrangement.Center and Alignment.CenterHorizontally in the Column. And that I am setting the size of the board in a Modifier given as a parameter. Meanwhile, I can add offsets to the modifier, and its works.