Maciej S
05/08/2023, 10:49 AMMaciej S
05/08/2023, 10:50 AMBodyTextField
),
• As the last field expands, I want the current line to be always visible and not disappear behind the keyboard, as more text is added.
In order to achieve the correct scroll behaviour as the user is typing, I set the reverse scrolling to true on the column. This is roughly the code:
@Composable
fun SomeScreen() {
val maxWidthModifier = Modifier.fillMaxWidth()
val focusRequester = remember { FocusRequester() }
Column {
Column(
modifier = maxWidthModifier
.verticalScroll(rememberScrollState(), reverseScrolling = true)
) {
PrefixedEmailTextField(
prefixStringResource = R.string.from_prefix,
modifier = maxWidthModifier
)
Divider()
PrefixedEmailTextField(
prefixStringResource = R.string.to_prefix,
modifier = maxWidthModifier.focusRequester(focusRequester)
)
Divider()
SubjectTextField(maxWidthModifier)
Divider()
BodyTextField()
}
}
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
}
This works as intended in the portrait, however in the landscape mode:
• There’s only space for a single line to be visible above the keyboard when entering the screen,
• The correct field is given the focus, however due to reverseScrolling = true param the whole column is scrolled to the very bottom to start with- the focused field is not visible.
Any ideas how to keep the scrolling behaviour as described while also showing the focused field in the landscape mode? I tried a couple of hacks but none worked so far.Maciej S
05/08/2023, 1:23 PMHalil Ozercan
05/08/2023, 2:12 PMMaciej S
05/08/2023, 2:40 PM