Reputation: 2836
Working on desktop application with Jetpack Compose and unable to center elements in a Column
as horizontalAlignment
attribute is not working. I've also seen many other answers saying to use horizontalArrangment
but that is also not working for desktop application.
Update: I've imported Alignment
from androidx.compose.ui
now and able to use CenterHorizontally
and error is gone but it's still not getting in centre.
Upvotes: 0
Views: 659
Reputation: 48
You need to use Align.CenterHorizontally and add it if you don't want to check your import
import androidx.compose.ui.Alignment
Column (
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
//content here
}
Upvotes: 0
Reputation: 61
you need to add
Column(
modifier = Modifier
.fillMaxWidth(),
horizontalAlignment = Alignment.CENTRE
){
....
}
because u need to state max width for the apps or you need to define the width/height of the column so that horizontal can be placed on the centre.
Upvotes: 2