TextFieldでキーボードのタイプを変える方法です。
.kt
@Composable
fun CopyButton() {
var text = remember { mutableStateOf("") }
TextField(
value = text.value,
onValueChange = { text.value = it },
label = { /*TODO*/ },
modifier = Modifier.padding(16.dp),
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Done,
)
)
}
こちらのコードのkeyboardType = KeyboardType.Text
ここの部分で変更することが可能です。
KeyboardTypeの種類
KeyboardType | 画像 |
---|---|
Text | ![]() |
Ascii | ![]() |
Number | ![]() |
Phone | ![]() |
Uri | ![]() |
![]() |
|
Password | ![]() |
NumberPassword | ![]() |
Decimal | ![]() |