哪里的Android View.scrollTo(X,Y)滚动到? [英] Where does Android View.scrollTo(x, y) scroll to?
问题描述
<一个href="http://developer.android.com/reference/android/view/View.html#scrollTo%28int,%20int%29"><$c$c>scrollTo(int x,int y)对 说:
x中的x位置滚动到
Y代表Y位置滚动到
<一个href="http://developer.android.com/reference/android/view/View.html#onScrollChanged%28int,%20int,%20int,%20int%29"><$c$c>onScrollChanged(int L,INT T,INT oldl,INT oldt) 说:
l电流水平滚动的起源。
l Current horizontal scroll origin.
T当前垂直滚动的起源。
t Current vertical scroll origin.
我想知道,找不到任何地方,在哪里是X,Y?左上?中央?我尝试了一些测试,并不能看着办吧。
What I would like to know and can't find anywhere, is where is x,y? Top left? Center? I tried a few tests and can't figure it out.
推荐答案
经过广泛的研究和测试,我终于明白了如何<一个href="http://developer.android.com/reference/android/view/View.html#scrollTo%28int,%20int%29">scrollTo()工作原理。
After extensive research and testing I've finally understood how scrollTo() works.
(0,0)
是坐标的的查看容器。当滚动到任何(X,Y)
点,在View 将被放置在(X,Y)
坐标。
(0,0)
are the coordinates to the top left corner of the View container. When scrolling to any (x,y)
point, the top left corner of the View will be placed at the (x,y)
coordinates.
如果视图是显示影像,的Bitmap ,大于的查看本身,滚动到(0,0)
将放置的View 的在图像的中心。通过这种方式,图像的左上角将位于( - DX / 2,-dy / 2)
键,右下角的 (MW - DX / 2,MH - DY / 2)
。 dX的
重presents =图像的宽度和的查看。而 DY
重presents图像的高度和的View 。
If the View is showing an image, Bitmap, larger than the View itself, scrolling to (0,0)
will place the View in the center of the image. This way, the top left corner of the image will be located at (-dX/2, -dY/2)
and the bottom right corner at (mW - dX/2, mH - dY/2)
. dX
represents the difference between the widths of the image and the View. And dY
represents the difference between the heights of the image and the View.
为了看右下角,而不是去通过它(低于或再往右),这是正确的呼叫: scrollTo(MW - IVW - DX / 2,MH - IVH - DY / 2);
In order to see the bottom right corner and not go passed it (lower or further to the right), this is the proper call: scrollTo(mW - ivW - dX/2, mH - ivH - dY/2);
所附图片显示了视图的图形重新presentation和位图图像定位。
The attached image shows the graphical representation of the View and Bitmap image positioning.
这篇关于哪里的Android View.scrollTo(X,Y)滚动到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!