Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Sie können Modifier.imeNestedScroll() auf einen scrollenden Container anwenden, um die IME automatisch zu öffnen und zu schließen, wenn zum unteren Rand des Containers gescrollt wird.
classWindowInsetsExampleActivity:AppCompatActivity(){overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)WindowCompat.setDecorFitsSystemWindows(window,false)setContent{MaterialTheme{MyScreen()}}}}@OptIn(ExperimentalLayoutApi::class)@ComposablefunMyScreen(){Box{LazyColumn(modifier=Modifier.fillMaxSize()// fill the entire window.imePadding()// padding for the bottom for the IME.imeNestedScroll(),// scroll IME at the bottomcontent={})FloatingActionButton(modifier=Modifier.align(Alignment.BottomEnd).padding(16.dp)// normal 16dp of padding for FABs.navigationBarsPadding()// padding for navigation bar.imePadding(),// padding for when IME appearsonClick={}){Icon(imageVector=Icons.Filled.Add,contentDescription="Add")}}}
Alle Inhalte und Codebeispiele auf dieser Seite unterliegen den Lizenzen wie im Abschnitt Inhaltslizenz beschrieben. Java und OpenJDK sind Marken oder eingetragene Marken von Oracle und/oder seinen Tochtergesellschaften.
Zuletzt aktualisiert: 2025-08-26 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-26 (UTC)."],[],[],null,["# Use keyboard IME animations\n\nYou can apply `Modifier.imeNestedScroll()` to a scrolling container to open and\nclose the IME automatically when scrolling to the bottom of the container.\n\n\n```kotlin\nclass WindowInsetsExampleActivity : AppCompatActivity() {\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n\n WindowCompat.setDecorFitsSystemWindows(window, false)\n\n setContent {\n MaterialTheme {\n MyScreen()\n }\n }\n }\n}\n\n@OptIn(ExperimentalLayoutApi::class)\n@Composable\nfun MyScreen() {\n Box {\n LazyColumn(\n modifier = Modifier\n .fillMaxSize() // fill the entire window\n .imePadding() // padding for the bottom for the IME\n .imeNestedScroll(), // scroll IME at the bottom\n content = { }\n )\n FloatingActionButton(\n modifier = Modifier\n .align(Alignment.BottomEnd)\n .padding(16.dp) // normal 16dp of padding for FABs\n .navigationBarsPadding() // padding for navigation bar\n .imePadding(), // padding for when IME appears\n onClick = { }\n ) {\n Icon(imageVector = Icons.Filled.Add, contentDescription = \"Add\")\n }\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/interop/MigrationOtherConsiderationsSnippets.kt#L66-L102\n```\n\n\u003cbr /\u003e\n\n**Figure 3.** IME animations."]]