Reputation: 9380
my textfield is overshadoved when I try to input data:
what can I do?
Upvotes: 1
Views: 978
Reputation: 9380
setContent {
ProvideWindowInsets {
JetpackComposeInsetsTheme {
Surface(
color = Color.Yellow,
modifier = Modifier.fillMaxSize()
) {
ContentView(modifier = Modifier
.navigationBarsWithImePadding())
}
}
}
}
Upvotes: 0
Reputation: 14787
AndroidManifest.xml
in your activity and this
will adjust the layout resize option.<activity
android:name=".ActivityName"
android:windowSoftInputMode="adjustResize"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Modifier
to the TextField.modifier = Modifier.navigationBarsWithImePadding(),
Refer this sample app for complete implementation.
Note
TextField
on the screen. I am working with forms and this doesn't work.TextField
must be the last view vertically.Upvotes: 1
Reputation: 23894
If you add this in you Activity, worked fine for me
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
...>
In addition to that, you can add a scroll to your screen... I'm adding my entire test code just to illustrate.
@Composable
fun BigFormScreen() {
var text by remember {
mutableStateOf("")
}
Column(
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painterResource(id = R.drawable.ic_android_orange),
contentDescription = null,
modifier = Modifier.size(300.dp)
)
TextField(value = text, onValueChange = { text = it })
}
}
Upvotes: 0