Android: Activities and layouts or a single custom view?

Started by
2 comments, last by madart 12 years, 11 months ago
I'm really interested in what's more common. Please note that the first option does not imply that you don't use custom view's at all, but that you don't write a single custom view that displays across the whole screen and takes control of any layouting and positioning.

I've tried to use the activity and layout system where possible so far. That is, for each scene of the game, I'm using a different activity, and whenever possible, I use a layout to arrange the screen. I've run into some shortcomings of the activity and layout system though, so I'm currently doing a mixture of both, and I'm considering moving to the single custom view approach. That would also have the benefit of being less Android specific and thus easier to port.
Advertisement
I'm just starting android development and have a rudimentary top down scrolling shooter working at the moment, I decided to go right for a single custom SurfaceView implementation to be used for the entirety of my development. This of course may change in the future but it's working out quite well so far.

If you like using pre-built buttons and sliders and other canned UI widgets use the built in view layouts and all that jazz... if you would prefer to get a black screen and use it as a blank canvas to draw all custom content with bitmaps and/or graphics primitives then just override the SurfaceView class and have at it.
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
For me, I like a black surfaceView and draw everything on it. Map, sprites, items, text, menus, touch screen controls. Gives me good freedom and doesn't deter the player from realizing he or she is on a phone or something. I want the player to feel as if he or she is using a handheld gaming system.
I'm pretty sure that SurfaceView is the best choice for games while layouts are widely used in different applications and tools (they can really simplify the development while being customizable as well). Actually there can not be a strict rule of course, when you have a task you usually can decide on this two approaches.
For me single custom view is a preferred choice anyway :)

This topic is closed to new replies.

Advertisement