2025-01-15
主要有Jetpack Compose组成。
@composable
fun UnitConverter( modifier: Modifier = Modifier){
	Column {
		Row{
		}
	}
}
textField, BasicTextField, OutlineTextField
单行文本用OutlineTextField,使用方式:
var inputValue by remember { mutableStateOf("") }
OutlinedTextField(value = inputValue, onValueChange = {
    // Here goes what should happen, when the value changes
	inputValue = it
})
实现按button,弹出界面(Toast)的功能。
Button(onClick = { Toast
    .makeText(context, "Thanks for clicking!",
        Toast.LENGTH_LONG).show() })
{
    Text("Click Me!")
}
Box{
    Button(onClick = {}){
        Text("Select")
        Icon(Icons.Default.ArrowDropDown, contentDescription = "Arrow Down")
    }
}
横向和纵向对齐
Column(
    modifier = Modifier.fillMaxSize(),
    verticalArrangement = Arrangement.Center,
    horizontalAlignment = Alignment.CenterHorizontally
) {}
Spacer()
Spacer(modifier = Modifier.height(16.dp))
负责空隙padding, 充满整个屏幕fillMaxSize()等间距调整。
Column(modifier = Modifier.fillMaxSize())
Spacer(modifier = Modifier.height(16.dp)) // 横向距离用width
style属性:MaterialTheme.typography
Text("Unit Converter", style = MaterialTheme.typography.headlineLarge)