Joao Goes
04/04/2020, 2:48 AMBottomSheetDialogFragment
using compose. That dialog has a TextField
. When click in the TextField
, the keyboard appears and the dialog move to top of keyboard (The expected behavior) but if I press any letter of keyboard, the dialog move to bottom of screen, behind of the keyboard. Code on thread.onCreateView
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.empty_layout, container, false)
(view as ViewGroup).setContent {
CustomDialogScreen()
}
return view
}
CustomDialogScreen
@Composable
fun CustomDialogScreen() {
val textFieldState: MutableState<TextFieldValue> = state { TextFieldValue() }
Surface(
border = Border(0.2.dp, Color.Black)
) {
Column(
modifier = Modifier.padding(8.dp)
) {
TitleText()
ItemTextField(textFieldState)
}
}
}
textField
@Composable
private fun ItemTextField(
state: MutableState<TextFieldValue>,
keyboardType: KeyboardType = KeyboardType.Text
) {
Box(
modifier = DrawBorder(
size = 0.2.dp,
brush = SolidColor(Color.Black),
shape = RoundedCornerShape(8.dp)
)
) {
TextField(
modifier = Modifier.padding(4.dp),
value = state.value,
textStyle = TextStyle(
fontSize = 14.sp
),
onValueChange = { state.value = it },
keyboardType = keyboardType
)
}
}