S
S
sam_u2017-03-10 13:53:19
Android
sam_u, 2017-03-10 13:53:19

Android view: how to get the bottom border of an element?

Tell me why it doesn't work, it seems like a simple thing.
I have a layout that has a scrollview and a root linearlayout.
New view-elements are dynamically added to the root element, they are displayed down, the scroll works, everything is fine.
But now I want to "scroll" the scrollview to the element I need on a certain event, I do
mScrollView.post(new Runnable() {
@Override
public void run() {
mScrollView.smoothScrollTo(0, mSelectedWheelItem.getBottom());
}
} );
But the effect is not the same, it always scrolls to the same place. I checked it in the debugger, it turned out that mSelectedWheelItem.getBottom() is always the same for each element, although the elements are 100% different.
How can I get the correct value for Y - the position of the bottom border of the view element I need?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question