0

I'm developing an application for android, and i have a big old GridView that's centered vertically in the screen, with all the cells visible.

What i want, is a function by which all cells are zoomed in by a factor of 3, letting the user scroll around in the gridview instead.

Sort of how Wordfeud does it if you're familiar with the game.

I've searched the webs and haven't found a satisfactory solution, i managed to find a way to alter the layout params in my adapter for the grid tiles, but it only stretches them vertically and not horizontally, also the whole app becomes slow and unresponsive until you've scrolled through the list and let the Grid reload all the views or whatever.

Any help at all is appreciated.

4

2 回答 2

0

最后,我改用了带有 Canvas 的自定义视图 - 比尝试将 GridView 弯曲成不应该的东西要容易得多。

于 2011-11-17T07:35:11.337 回答
0

我知道你问已经有一段时间了,但我有一个类似的问题,我花了很长时间才解决,所以我希望其他人可能会偶然发现这个问题。我最终扩展了 GridLayout 类并连接了一个实例

private class ScaleGestureListener
    extends ScaleGestureDetector.SimpleOnScaleGestureListener

在构造函数中:

        scaleDetector = new ScaleGestureDetector(context, new ScaleGestureListener());

因为它是一个视图组,所以覆盖 dispatch... 而不是 on... 方法:

     @Override
     public boolean dispatchTouchEvent(MotionEvent ev){
         scaleDetector.onTouchEvent(ev); 
         super.dispatchTouchEvent(ev);
         return true;
     }

    @Override
    public void dispatchDraw(Canvas canvas) {
        String disp = String.valueOf(mScaleFactor);
        Log.v(TAG, "dispatch draw " + disp);

        canvas.save();
                 // i have some other stuff in here specific to my app 
        canvas.scale(mScaleFactor, mScaleFactor);
        super.dispatchDraw(canvas);
        canvas.restore();
    }
于 2014-03-07T15:34:58.450 回答