mrmclovin
mrmclovin

Reputation: 1123

Android: What view to use for a image puzzle game?

I'm making a 3x3 image square puzzle game for android.

I have my Level class which should contain all the Tile instances. (Tile is a subclass of android.widget.ImageView). My question is what kind of view should Level subclass? And how can I set the position of each tile/imageview in the Level view?

EDIT: Forgot to say that I want to be able to animate x/y coordinates of the tiles!

Cheers!

Upvotes: 1

Views: 1725

Answers (2)

Lumis
Lumis

Reputation: 21639

If you want to animate tiles then a table layout would restrict their movement and make them disappear when they go over the each table cell's border. If the margin of each tile is big enough then the tile could move only within that margin in a table cell.

Other way to do it is to use RelativeLayout and position each tile using top and left margin from the parent independently of each other. The problem with this is how to place them in the middle for different screen resultions. One way is to center the RealtiveLayout within a LinearLayout and use dp pixels for all settings.

Upvotes: 1

Tanmay Mandal
Tanmay Mandal

Reputation: 40168

I think you must go with android TableLayout . Again you can take a look at the example .

Just use ImageView here

<TableRow>
   <ImageView
................
................
  />
</TableRow>

Upvotes: 0

Related Questions