Scrollview vertical and horizontal in android

前端 未结 11 961
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 05:30

I\'m really tired looking for a solution for vertical and horizontal Scrollview.

I read that there are not any views/layouts in the framework which implement this fe

11条回答
  •  天命终不由人
    2020-11-22 06:01

    Since this seems to be the first search result in Google for "Android vertical+horizontal ScrollView", I thought I should add this here. Matt Clark has built a custom view based on the Android source, and it seems to work perfectly: Two Dimensional ScrollView

    Beware that the class in that page has a bug calculating the view's horizonal width. A fix by Manuel Hilty is in the comments:

    Solution: Replace the statement on line 808 by the following:

    final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
    


    Edit: The Link doesn't work anymore but here is a link to an old version of the blogpost.

提交回复
热议问题