Reputation: 323
In short: using Jetpack Compose, the keyboard overlaps the TextField when it is opened in an AlertDialog. I've tried everything I've found:
added android:windowSoftInputMode="adjustResize"
to the Activity in AndroidManifest.xml
set decorFitsSystemWindows = false
on the DialogProperties
called WindowCompat.setDecorFitsSystemWindows(window, false)
for the dialog's window
called WindowCompat.setDecorFitsSystemWindows(window, false)
in the Activity's onCreate()
method
used this ImeState
approach from: https://www.youtube.com/watch?v=kgoJfl_Oc5E
used the BringIntoViewRequester
:
modifier
.onFocusEvent {
if (it.isFocused) {
coroutineScope.launch {
delay(200)
bringIntoViewRequester.bringIntoView()
}
}
}
.bringIntoViewRequester(bringIntoViewRequester)
I've created a GitHub repository with a demo project: Demo project - TextField covered by keyboard
Can you help me to understand what am I missing? I'm completely out of ideas.
Based on the answer of @Shubham Thorat, I used adjustPan
in the following way:
android:windowSoftInputMode="adjustPan"
LaunchedEffect(imeState.value)
:
WindowCompat.setDecorFitsSystemWindows(wnd, false)
wnd.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
Upvotes: 6
Views: 4425
Reputation: 114
I have an answer, which will always work for modal bottom sheet with a textfiled. Here is a basic implementation.
skipPartiallyExpanded
argument to true.ModalBottomSheet
.Code Example
val sheetState = rememberModalBottomSheetState(true)
val inputValue = remember{ mutableStateOf("") }
ModalBottom(
onDismissRequest={},
sheetState = sheetState,
modifier = Modifier.fillMaxWidth(),
height = 300.dp, //assuming the height is 300 dp
content = {
Column(modifier = Modifier.padding(10.dp){
TextField(
modifier = Modifier.fillMaxWidth(),
value = inputValue,
onValueChanged= { inputValue.value = it },
)
}
}
)
Upvotes: 0
Reputation: 7
android:windowSoftInputMode="adjustResize"
Column(
modifier = Modifier
.fillMaxHeight()
.imePadding()
)
Upvotes: 0
Reputation: 76
Can you try this one:
android:windowSoftInputMode="adjustPan"
Upvotes: 6
Reputation: 4176
Try this on your column:
Column(
modifier = Modifier
.fillMaxHeight()
//add this
.imePadding()
.verticalScroll(scrollState),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(boxHeight)
.background(LightYellow)
) {
}
CustomTextField(textFieldValueState = textFieldValueState)
}
Upvotes: 3