looking to implement a wall (GridView?) that goes off-screen and user can touch to move it around

后端 未结 4 1833
半阙折子戏
半阙折子戏 2021-02-05 08:13

Desired effect I have a bunch of small images that I\'d like to show on a \"wall\" and then let the user fling this wall in any direction and select an image.

4条回答
  •  既然无缘
    2021-02-05 08:48

    A GridView can have content that extends beyond the size of the screen, but only in the vertical direction.

    Question: What is the best widget to use to implement the desired effect ?
    The are no default widgets (at least prior to 3.0) which implement 2D scrolling. All of them implement 1D (scrolling in one direction) only. Sadly the solution to your problem is not that easy.

    You could:

    • Place a TableLayout inside a custom ScrollView class, and handle the touch events yourself. This would allow you to do proper 2D panning, but would not be so good for large data-sets since there would be no view recycling
    • Modify GridView if possible to enable horizontal scrolling functionality (probably the best solution if you can do it)
    • Try putting a TableLayout inside a ScrollView (with layout_width="wrap_content) which you put inside a HorizontalScrollView - though this may work it wouldn't be the optimum solution
    • Do something with OpenGL and draw straight to a canvas - this is how the default Gallery 3D app does it's "wall of pictures"

提交回复
热议问题