-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
feat: support contentInset
on Android
#49145
base: main
Are you sure you want to change the base?
feat: support contentInset
on Android
#49145
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kirillzyusko, thanks for the PR.
Have you checked whether this works properly in the New Arch?
post(new Runnable() { | ||
@Override | ||
public void run() { | ||
int maxScrollY = getMaxScrollY(); | ||
// If the current scroll offset is now beyond the new maximum, | ||
// adjust it to the new maximum. | ||
if (getScrollY() > maxScrollY) { | ||
scrollTo(getScrollX(), maxScrollY); | ||
} | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this show a flicker or an animation or does it happen immediately? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it happens immediately. Basically it fixes a very strange problem. Without this code problems looks like this:
telegram-cloud-document-2-5264877611309358434.mp4
Even though I can clearly see that setter gets called:

There is still a frozen area of the contentInset
. But it disappear as soon as I start scrolling. So I thought to add scrollTo
programmatically. Maybe there is a better fix for this problem - let me know if you find one 🙌
I tested only new architecture 🙂 However I have a question about In fact it's very draft changes, because I assume at the moment |
Great, thanks for confirming!
No, we have a script to generate it, but it only runs in the internal infra, sadly. So we have to run it ourselves after we import PRs
I don't have a lot of context on the why. I also don't know about all those implications as android is not really my area of expertise. But I'll make sure to pass this around to other Android engineers that might have context/knowledge on this. |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Awesome! Thank you! As I said before - I'm ready to implement missing pieces, just would like to know what exactly I should implement 🙌 😊 Thank you for your assistance ❤️ |
@javache Mentioned that, for sure we need to have the HorizontalScrollView implementation (but you knew about that!) There might be some other gotchas, and he is definitely more expert on Android than me. |
b1c1f8e
to
0ee7413
Compare
@javache @cipolleschi I encountered one problem and I really don't understand the root cause 🤔 Basically if I apply - item 0
- item 1
- ...
- item N
- (paddingTop)
- (paddingBottom) I've tried to workaround that problem by: View content = getContentView();
content.setTranslationY(top);
setPadding(left, top, right, bottom);
scrollBy(0, top);
// simulate iOS behavior
setClipToPadding(false); And it kind of works, but since we shift the content of My other idea was to add - marginTop
- item 0
- item 1
- ...
- item N
- (paddingBottom) <-- `paddingTop` will be compensated by `marginTop` However that approach doesn't work at all 🙃 I'm not allowed to change paddings of React views because they are laid out by YOGA and all my manual changes get ignored? We can also have a conversation in discord, if you think that it'll be easier/faster for you 🙂 |
Summary:
At the moment
contentInset
property is available only on iOS. In this PR I'm adding the support for this property via applying additional padding directly toScrollView
native component.Changelog:
[ANDROID] [ADDED] - support
contentInset
on AndroidTest Plan:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2025-02-03.at.19.18.35.mp4
telegram-cloud-document-2-5262625811495674255.mp4