-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ScrollView.scrollToEnd on Android natively
Summary: This is a followup for #12088 and implements the scrolling to end on Android natively rather than sending a large scroll offset from JS. This turned out to be an OK amount of code, and some reduction in the amount of JavaScript. The only part I'm not particularly happy about is: ``` // ScrollView always has one child - the scrollable area int bottom = scrollView.getChildAt(0).getHeight() + scrollView.getPaddingBottom(); ``` According to multiple sources (e.g. [this SO answer](http://stackoverflow.com/questions/3609297/android-total-height-of-scrollview)) it is the way to get the total size of the scrollable area, similar to`scrollView.contentSize` on iOS but more ugly and relying on the fact the ScrollView always has a single child (hopefully this won't change in future versions of Android). An alternative is: ``` View lastChild = scrollLayout.getChildAt(scrollLayout.getChildCount() - 1); int bottom = lastChild.getBottom() + scrollLayout.getPadd Closes #12101 Differential Revision: D4481523 Pulled By: mkonicek fbshipit-source-id: 8c7967a0b9e06890c1e1ea70ad573c6eceb03daf
- Loading branch information
1 parent
56595bf
commit ad8cbb6
Showing
6 changed files
with
59 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What about if we have left padding as well?
I think this solution is more complete:
Or may be just simpler way: