简体   繁体   中英

android: Manipulating the visible view contained in a Scrollview

I have a TableLayout within a Scrollview. The Table layout defines a form, whose individual rows are text views, edittext or buttons. A combination of each of these text views, edittext or buttons represents a question, which is linked to a specific category. I have another list, which displays a list of the category. When I select a category, I want the scroll view to display the set of question that starts with that particular category.

The issue with implementing this functionality is: scroll view provides a method scrollTo (int x, int y), using which I can display the view at a particular x and y position. What is the best way to implement this:

1) determine the exact height of each view that is added to my table layout (how??) and then add them to get the starting y position of the question that starts with category 2, 3, 4, ...... If this can be done, perhaps I can pass on this value to the category group selection listener.

Or is there a better way to do it?

You're going to want to measure the child or children before the desired scroll point, find the sum of y axis, and scroll there.

measureChild()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM