且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拖动图像只会水平或垂直的机器人?

更新时间:2023-11-19 10:11:04

首先,把滚动型 Horizo​​ntalScrollView 的ImageView 最里面的滚动型里面。

First, put a ScrollView inside a HorizontalScrollView, and the ImageView inside the innermost ScrollView.

层次结构如下所示:

  LinearLayout (ROOT)
  |
  +-- ScrollView (V)
       |
       +-- LinearLayout (1)
            |
            +-- HorizontalScrollView (H)
                |
                +-- LinearLayout (2)
                    |
                    +-- ImageView

让我解释一下:

And let me explain:

(V)在垂直方向上滚动而已。

(V) scrolls in vertical direction only.

(H)在水平方向上滚动而已。

(H) scrolls in horizontal direction only.

(1)(2)是用于线性布局紧跟任何ScrollViews。因为,一个滚动型只能承载一个直接子。

(1) and (2) are linear layouts used immediately following any ScrollViews. Because, a ScrollView can host only one direct child.

关于命名注:这里只有滚动型,而没有的VerticalScrollView

Note on naming: There's only "ScrollView", and not "VerticalScrollView"

什么当您将发生在的ImageView

,如果是水平的, Horizo​​ntalScrollView 将处理的动作,而滚动型都不会坐视不管。而如果动作是垂直的,在滚动型将处理的动作,而 Horizo​​ntalScrollView 都不会坐视不管。

Based on the very first direction of the gesture you make, if it's horizontal, the HorizontalScrollView will process the action, and the ScrollView will sit idle. And if the action was vertical, the ScrollView will process the action, and HorizontalScrollView will sit idle.