question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There's a space between content and keyboard when using imePadding

See original GitHub issue

Describe the bug

There’s a space between content and keyboard when using imePadding and navigationBarsWithImePadding

To Reproduce

Steps to reproduce the behavior:

  1. When TextField is full I hid the keyboard
  2. When pressed again it pushed the TextField up, but the there’s a weird space between them

Screenshots?

My TextField is wrapContentHeight and this is when i paste a long text

When i pressed back:

Pressed on TextField again:

Environment:

  • Android OS version: [Android 8.0.0]
  • Device: [LG V30 and Emulator Pixel 4XL]
  • Accompanist version: [v0.15.0]

On this screen i have bottomSheetLayout and bottomBar. It worked fine in another screen, but i couldn’t find sth wrong it my code tho.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alexvanyocommented, Feb 3, 2022

Thanks for the simple example! This is expected, but as you pointed out somewhat confusing behavior.

How insets are combined is in a maxOf sense, rather than a strict additive sense.

So putting some numbers to it: Let’s say the navigation bar inset is 20 pixels from the bottom of the screen, and the top of the IME is 100 pixels from the bottom of the screen.

Then navigationBarPadding() will have a bottom value of 20 pixels, and imePadding() will have the bottom value of 100 pixels. If both are applied, then the total padding will be 120 pixels, but this is 20 pixels too high: the top of the IME is only 100 pixels from the bottom of the screen.

navigationBarsWithImePadding() “combines” these two types of insets, but it doesn’t do so just by adding them. Instead it takes the max of each. So the bottom padding of navigationBarsWithImePadding will be just 100 pixels.

If you wanted to split up the paddings, you will have to do that subtraction calculation yourself with the current accompanist APIs, since there isn’t communication from the parent to the child saying “I’ve already handled this portion of the insets”.

That communication is currently being experimented with insets support in androidx.compose, which would allow both approaches to work as you’d expect.

0reactions
svenjacobscommented, Feb 3, 2022

Thanks Alex for this detailed explanation. I know understand why Accompanist insets work that way 👍🏼

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextField IME padding in LazyColumn , Compose
setDecorFitsSystemWindows(window,false) in the onCreate Method before setContent and I want to make text appear above the keyboard at all times ...
Read more >
Android Jetpack Compose: Inset Padding Made Easy - Medium
Sometimes we want to expand our app content's view into these insets area, or we want to pad our view not to be...
Read more >
Insets for Jetpack Compose - Accompanist - Google
The library now has experimental support for WindowInsetsAnimations , allowing your content is react to inset animations, such as the on screen-keyboard (IME) ......
Read more >
Keyboard Handling In Jetpack Compose — All You Need To ...
The system resizes your layout to the available space, to make content accessible when the keyboard appears on the screen.
Read more >
Text Field - Text goes below the IME [192043120]
The Text goes below the keyboard Because Of The Scroll State ... affects almost any use of TextField s within a scrolling area...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found