创建的点的一个格 [英] create a grid of dots

查看:186
本文介绍了创建的点的一个格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建点的网格非常喜欢这个游戏:的https://play.google.com/store/apps/details?id=com.nerdyoctopus.gamedots&hl=en

I would like to create a grid of dots very much like in this game: https://play.google.com/store/apps/details?id=com.nerdyoctopus.gamedots&hl=en

这样做的目的是为每个点是可触摸的,这样我就可以在这里认识该特定点是和它的其他信息。

The aim is for each dot to be touchable, so I can recognise where that particular dot is and other information about it.

我真的不知道从哪里开始。难道我想创建一个自定义的查看与所有我想要的信息,然后点创建了多个版本?然后做我安排他们与 setTranslation()方法的网格,或者它会更好地使用的LayoutParams 与偏移?

I don't really know where to start. Do I want to create a custom View for a dot with all the information I want, and then create multiple versions of it? And then do I arrange them in a grid with the setTranslation() method, or would it be better to use LayoutParams with offsets?

如果我创建了自己的点即扩大查看,然后我可以有很多不同的信息/方法添加到它 - 我可以在理论上有一个 changeColor()方法。这是最好的方法是什么?

If I created my own "Dot" that extended "View", then I could add a lot of different information/methods to it - I could theoretically have a changeColor() method. Is this the best way?

A GridView控件是不是我在想什么的(据我所知),因为它基本上是一个不同的风格的ListView

A GridView is not what I am thinking of (as far as I know) as it is basically a different style of ListView.

有很多的问题在这里!我已经看过了一些在这里计算器和其他地方的问题,但没有显示/解释我是如何应该开始。

There are lots of questions here! I have looked at a number of questions here on StackOverflow and elsewhere, but none show/ explain how I should start.

推荐答案

我会用的 TableLayout 这一点。一个GridView是一个ListView的一个网格的形式同等学历,滚动,查看回收和诸如此类的东西,那是不是你所需要的。一个网格布局,为德尔马斯建议,将是一个更好的选择,如果你想建立一个静电网,但在我的经验,这是不容易的列之间平均分配的可用空间,如果你将需要改变电网在游戏过程中分布,TableLayout是更容易使用。

I would use a TableLayout for this. A GridView is the equivalent of a ListView in a 'grid' form, with scrolling, view recycling and whatnot, and that is not what you need. A GridLayout, as Dalmas suggested, would be a much better option if you want to build a static grid, but in my experience it is not easy to distribute the available space equally between columns, and if you are going to need to alter the grid distribution during the game, a TableLayout is much easier to use.

有关的点,是的,有可配置的颜色的自定义视图会去解决它的最好办法。

For the dots, yes, a custom view with a configurable color would be the best way to go around it.

这篇关于创建的点的一个格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆