Change the behaviour of a GridView to make it scroll horizontally rather than vertically

大兔子大兔子 提交于 2019-11-30 10:01:27

There is setRotation in API 11. You'll have to rotate the gridview by 90 degrees and child views by -90 degrees.

Documentation: http://developer.android.com/reference/android/view/View.html#setRotation(float)

Update:

To get a 3d effect on views following APIs would be useful

setCameraDistance(float) - set the z axis distance(depth)

setRotationX(float) - set the horizontal axis angle

setRotationY(float) - set the vertical axis angle

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.

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.
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!