我想要像一个 UI
元素的GridView
,我想它的全部功能,但希望它是水平滚动而不是垂直。
I want to make a UI
element like a GridView
, I want it's complete functionality but want it to be horizontally scrollable rather than vertically.
通过水平滚动我的意思是应该建立这种方式,而不是放在一个 HorizontalScrollView
。
By horizontal scroll I mean it should be built that way and not put in a HorizontalScrollView
.
我会自定义的GridView
将有固定的行
说 4-5号
和列
应扩展
根据项目的适配器。你可以把它看成什么样的原生的GridView
则正好相反,但它应保持的功能。
My would be Custom GridView
will have fixed number of rows
say 4-5
and the columns
should be extensible
based on number of items in the Adapter
. You can think of it as the opposite of what the native GridView
does, yet it should maintain the functionality.
我已经看过了如何的GridView
是由谷歌实现源$ C $ C,但我能够非常少的理解,并开始使查看
从头开始似乎没有一个好主意,因为我怕我不能做到公正,以内存优化的方式谷歌做到了。
I have looked at the source code of how a GridView
is implemented by Google, but I am able to understand very less and starting to make the View
from scratch doesn't seem to be a good idea, since I am afraid I will not be able to do justice to memory optimization's the way Google did it.
我已经观察到,的GridView
扩展 AbsListView
,所以我的问题是,它是 AbsListView
,它可以让一个的GridView
垂直滚动,然后从适配器添加的项目,或者是的GridView
这增加了垂直滚动的能力?我应该调整的GridView
或 AbsListView
?
I had observed that GridView
extends AbsListView
, so my question is, is it AbsListView
which lets a GridView
scroll vertically and add items from the adapter, or is it GridView
which adds the vertical scrolling ability? Should I tweak GridView
or AbsListView
?
这将是更好的知道,如果有一些东西,已经做什么,我要怎么办?
It would be even better to know if there's something which already does what I want to do?
这已在本地画廊和Android蜂窝的YouTube应用3.1及以上的实施。因此,如果任何人有一个想法,请详细说明。
This has already been implemented in native Gallery and YouTube app of Android Honeycomb 3.1 and above. So if anyone has an idea, please elaborate.
的蜂巢画廊的应用程序快照:
的蜂窝YouTube应用程序快照:
有 setRotation
的API 11.你将有90度和儿童旋转GridView控件意见-90度。
There is setRotation
in API 11. You'll have to rotate the gridview by 90 degrees and child views by -90 degrees.
文件:http://developer.android.com/reference/android/view/View.html#setRotation(float)
要获得下列API将是有益的意见了3D效果
To get a 3d effect on views following APIs would be useful
setCameraDistance(float) - 将Z轴的距离(深度)
setCameraDistance(float) - set the z axis distance(depth)
setRotationX(float) - 设置水平轴的夹角
setRotationX(float) - set the horizontal axis angle
setRotationY(float) - 设置垂直轴的夹角
setRotationY(float) - set the vertical axis angle
设置相机距离半个屏幕的高度。然后设置基于的rotationX在屏幕上的视图的位置。旋转角度应该是这样的(20,10,0,-10,-20)由左到右。稍后,您可以与角度的rotationY发挥得到一些高度认知。
Set the camera distance to half of the screen height. Then set the rotationX based on the view's location on screen. The rotation angles should be something like (20, 10, 0, -10, -20) from left to right. Later you can play with rotationY angles to get some height perception.
不要在扩展的GridView
的被覆盖的布局
方法中的所有设置。
Do all setting in extended GridView
's overriden layout
method.
@override
void layout(int t, int l, int r, int b) {
super.layout(t, l, r, b);
...
int columnStart = getFirstVisiblePosition()/no_of_columns;
int columnEnd = getLastVisiblePosition()/no_of_columns;
loop from 'columnStart' to 'columnEnd' 'no_of_colmns' times {
// set the camera distance and rotationX to views
// depending on the position of a view on screen.
}
}