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")}}}
[null,null,["最后更新时间 (UTC):2025-08-26。"],[],[],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."]]