Created
September 7, 2021 14:11
-
-
Save ruyut/ea95081aafe39eebb4cac6bd35932f51 to your computer and use it in GitHub Desktop.
Jetpack Compose 使用Column達成 垂直 水平 置中
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app.ruyut.jetpackcompose | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.foundation.layout.Arrangement | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Text | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
class MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
Column( | |
modifier = Modifier.fillMaxSize(),// 最大化 | |
verticalArrangement = Arrangement.Center, // 垂直置中 | |
horizontalAlignment = Alignment.CenterHorizontally // 水平置中 | |
) | |
{ | |
Text(text = "Ruyut.com") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment