开发者

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 tex开发者_Go百科t 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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜