0

I have an iOS version of a real simple board game here. It's a 2D grid displayed with isometric view. It is based purely on UIKit, meaning the graphics are drawn using UIImage and UIImageView. No need for OpenGL or any other more sophisticated graphics frameworks. Performance is just fine.

I'd like to port it over to Android. My idea was to simply convert it to use ImageView and position them absolute. But then I read that AbsoluteLayout is deprecated (for a good reason, the screen sizes vary too much). But how can I then position my views? In my case, I will have to take care of proper sizing and positioning myself anyway.

The layout of the game looks like this: Isometric board

Krumelur
  • 32,180
  • 27
  • 124
  • 263
  • If its a 2D grid i would recommend Grid Layout or Table Layout, they are easy to use and should do the trick. – JanBo Oct 13 '13 at 16:51
  • @JanBo Well, it's more like this: http://i.imgur.com/919bb.png – Krumelur Oct 13 '13 at 16:52
  • 1
    Hm, then my comment wont do you much good. Edit your question with that pictures it will give a clue what you are looking for and thus give you better answers. – JanBo Oct 13 '13 at 16:55

2 Answers2

0

You could try a RelativeLayout, which lets you positioning its children relatively to other subviews, and play with margins/paddings as well. You also have GridLayout, but not sure how hard it would be to position your assets given an isometric perspective.

ssantos
  • 16,001
  • 7
  • 50
  • 70
0

If its a grid game as maze or puzzle use linearlayout with vertical orientation. You can consider this layout as the board and start dynamically nserting another liner layouts with horizontal orintation into it as rows. Each row should have your image views.

You can configure your board linear layout with 2d array that used to map whats on the screen to that array. You can also get screen width easily to let your board exactly match screen width. Divide screen width with the 2d array number of columns. Keep it dynamically so you can edit your board 2d array and all will be reflected. And more you can maybe randomly generate you 2d array.

hasan
  • 23,815
  • 10
  • 63
  • 101
  • See the image I added. I doubt that a real layout is what I need. I really need pixel based positioning I think. – Krumelur Oct 13 '13 at 17:23
  • @Krumelur you can still get pixel level control with RelativeLayout by using margins. Just be sure to use `dp` instead of actual pixels, that will help it scale up to different screen sizes reasonably well. – FoamyGuy Oct 13 '13 at 17:42
  • @FoamyGuy Do you have any examples at hand? I'm a total beginner on Android. :-( – Krumelur Oct 13 '13 at 17:55
  • @Krumelur I made a video a while back that introduces you to RelativeLayout: https://www.youtube.com/watch?v=j1T5LkxCfZQ – FoamyGuy Oct 13 '13 at 20:46
  • I developed two days ago a similar game with a similar grid as yours. As I explained in my answer. – hasan Oct 13 '13 at 22:12
  • Do you want your grid to be drawn like this. "Diagonally" – hasan Oct 13 '13 at 22:15