Android 模拟器键盘不显示但响应点击

问题描述 投票:0回答:1

我正在 Android Studio 中工作,我为一个简单的小费计算器应用程序完成了一个无错误的代码,但是当我在模拟器中启动它并单击文本字段时,UI 向上移动,但数字键盘没有出现。

当我点击数字应该在的位置时,它会如何响应,但它就是不显示?

这是与键盘有关的代码:

 EditNumberField(
        value = amountInput,
        label = R.string.bill_amount,
        keyboardOptions = KeyboardOptions.Default.copy(
            keyboardType = KeyboardType.Number,
            imeAction = ImeAction.Next),
        onValueChanged = { amountInput = it },
        modifier = Modifier
            .padding(bottom = 32.dp)
            .fillMaxWidth()
    )

    EditNumberField(
        label = R.string.how_was_the_service,
        keyboardOptions = KeyboardOptions.Default.copy(
            keyboardType = KeyboardType.Number,
            imeAction = ImeAction.Done),
        value = tipInput,
        onValueChanged = {tipInput = it},
        modifier = Modifier
            .padding(bottom = 32.dp)
            .fillMaxWidth())

    Text(
        text = stringResource(R.string.tip_amount, tip),
        style = MaterialTheme.typography.displaySmall
    )
    Spacer(modifier = Modifier.height(150.dp))
}

}

@Composable
fun EditNumberField(
    @StringRes label: Int,
    keyboardOptions: KeyboardOptions,
    value: String,
    onValueChanged: (String) -> Unit,
    modifier: Modifier = Modifier
) {

TextField(
    value = value,
    onValueChange = onValueChanged,
    singleLine = true,
    modifier = modifier,
    label = { Text(stringResource(label)) },
    keyboardOptions = keyboardOptions
)

}

android android-studio android-emulator
1个回答
0
投票

这是一个模拟器问题,只需重新启动即可解决! IT 的第一条规则,伙计们,不要成为我。

© www.soinside.com 2019 - 2024. All rights reserved.