动态改变GridView的大小
我正在开发一个 Android 应用程序,我有一个很大的旧 GridView,它在屏幕中垂直居中,所有单元格都可见。
我想要的是一个将所有单元格放大 3 倍的函数,让用户在 gridview 中滚动。
如果你熟悉这个游戏的话,就像《Wordfeud》的做法一样。
我在网上搜索过,没有找到满意的解决方案,我设法找到一种方法来改变适配器中网格图块的布局参数,但它只垂直拉伸它们,而不是水平拉伸,整个应用程序也变得很慢并且没有响应,直到您滚动列表并让网格重新加载所有视图或其他内容。
任何帮助都值得赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后,我使用了带有 Canvas 的自定义视图 - 比尝试将 GridView 弯曲成不应该的东西要容易得多。
In the end, i used a custom view with a Canvas instead - much easier than trying to bend GridView into something it's not supposed to be.
我知道你问这个问题已经有一段时间了,但我也遇到了类似的问题,花了很长时间才解决,所以我希望其他人可能会偶然发现这个问题。我最终扩展了 GridLayout 类并
在构造函数中连接了一个实例:
因为它是一个视图组,所以重写调度...而不是 on... 方法:
I know it's been a while since you asked, but I had a similar problem that it took me a long time to solve, so I'm hoping someone else may stumble on this. I ended up extending the GridLayout class and hooking up an instance of
in the constructor:
since it's a view group, override the dispatch… instead of the on… methods: