-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyboardAvoidingView doesn't work on Android #650
Comments
@gkassym do you use |
Yes, i use:
Also i noticed this warning: |
I don't think so 🙂 Can you try to apply a patch from software-mansion/react-native-screens#2301 and re-build the project? It may solve the problem 🙂 |
I applied the patch you recommended. It works. 👍 |
@gkassym did you try to add |
Nice 🔥 statusBarTranslucent works. Another thing I noticed is that the keyboard opens first in Android and then it moves the text input. Have you seen anything like this? Screen.Recording.2024-10-23.at.16.01.15.mov |
Yes @gkassym It happens if you animate I believe I answered on your questions and the conversation goes into a different direction - can I close this issue? |
Sure, thanks. Happy Coding!!! |
…ew` (#830) ## 📜 Description Added new `behavior="translate-with-padding"` for `KeyboardAvoidingView`. ## 💡 Motivation and Context The new mode ideally fits for chat-like applications and has very good performance. The implementation was mostly inspired by [WindowInsetsAnimation](https://github.com/android/user-interface-samples/tree/main/WindowInsetsAnimation) sample app. However when I tried to replace `translateY` to `0` and apply `paddingBottom` which is equal to previous `translateY` I had flashes on Android (mostly because of nature of Android - transform properties (e.g., `translateY`) only trigger a **repaint** (no _reflow_) and are applied **immediately**. Changes to **layout** properties like **padding** force the Android rendering system to recalculate layout (**reflow**), which can take an extra frame to resolve). So instead of switching those properties I decided to keep `translateY` and add `paddingTop` (in the end of animation to resize the container). Since we change `paddingTop` only in the beginning or in the end of animation the transition is unbelievable smooth, because we trigger layout re-calculation only once (so in terms of complexity new approach is `O(1)` vs `O(n)`). Closes #719 (comment) software-mansion/react-native-reanimated#6854 #650 (comment) ## 🔢 Things to do - write e2e tests for chat FlatList example screen (to cover new functionality with e2e tests); - update documentation page with detailed explanation of modes and when to use each of them. ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - added new `"translate-with-padding"` behavior for `KeyboardAvoidingView` - added `useTranslateAnimation` hook; - integrate `useTranslateAnimation` with `"translate-with-padding"`; - update example app to more performant implementation; ### Docs - mention new behavior; ## 🤔 How Has This Been Tested? Tested both paper and fabric on: - iPhone 15 Pro (iOS 17.5); - Medium phone (API 35). ## 📸 Screenshots (if appropriate): ### Paper |Android|iOS| |--------|---| |<video src="https://github.com/user-attachments/assets/f8d35138-77ae-432e-a95b-97104a01b4fe">|<video src="https://github.com/user-attachments/assets/93db0cdb-4ef4-4fb0-8cd4-9ada0312ff7d">| ### Fabric |Android|iOS| |--------|---| |<video src="https://github.com/user-attachments/assets/e2398edc-d6c0-41e8-8fdc-eb95e7741f74">|<video src="https://github.com/user-attachments/assets/379567d3-5d7a-482c-81af-ab359356a11c">| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
@gkassym I added new New mode is available in |
Hi @kirillzyusko, wow, nice. I will check. Thanks 🔥 |
KeyboardAvoidingView doesn't work on Android
I installed the react-native-keyboard-controller library and ran pod install. I wrapped the root component with KeyboardProvider, and everything works as expected on iOS. However, on Android, it doesn't work at all. I also tried using KeyboardAwareScrollView, but encountered the same issue—it doesn't work. Then, I attempted to use KeyboardEvents, but the listener callback doesn't trigger when the keyboard opens or closes. As mentioned, iOS works perfectly. I performed a clean build, cleared the Android/app build, cleaned the Gradle files, and removed node_modules, but none of these steps resolved the problem.
I believe the native code wasn't installed correctly. Any ideas?
Code snippet
Screenshots
Screen.Recording.2024-10-22.at.10.51.59.mov
Smartphone (please complete the following information):
RN version: 0.75.3
RN architecture: Old
JS engine: Hermes
Library version: 1.14.2
React-native-reanimated: 3.16.1
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: