Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRifqi Fahmi
23,164 PointsI still curious about the end value !
In this video ben set the end value by calling this method
int end = view.getTop() + view.getMeasuredHeight() - 1;
can someone elaborate this ? Thanks :D
2 Answers
J.D. Sandifer
18,813 PointsOn that line, we're trying to set the int "end" to equal the bottom position of the view. This is possible by getting the top position of the view, adding its height, and subtracting 1.
I don't know what actual unit is used in these functions, but I can explain it in terms of generic pixels where 0 is the top of the screen. An example view might have a top at row 0 and be 40 pixels tall. That would mean the bottom is at row number 39. The code would then evaluate to 0 + 40 - 1 = 39 for that example - just what we want!
(It's like arrays where the first index is 0. An array with 40 items would be indexes 0 - 39.)
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 PointsI found that view.getBottom() is also working just like view.getTop + view.getMeasuredHeight() - 1
Rifqi Fahmi
23,164 PointsRifqi Fahmi
23,164 Pointsnice thank you! :D
Varun Dixit
570 PointsVarun Dixit
570 PointsJ.D. Sandifer why don't we call the getBottom() method like we do for getTop();
Kareem Jeiroudi
14,984 PointsKareem Jeiroudi
14,984 PointsTrue, I also wondered why he didn't use
getBottom()
simply.