Home » Android » how to tilt a layout in android?

how to tilt a layout in android?

Posted by: admin June 15, 2020 Leave a comment


i need to tilt a layout in android about 45 degree anticlockwise.
i want to implement a game in android as stackopolis .is there any method to align tiles as in the game.I have the tile image,and now i use canvas to align this.but there i cannot get the click event and it is difficult to align tiles.is grid view is compatable.any new idea.
i have these images with me.this is the main background

main background grid


i want to align this tile in grid.and need click event as in the stackopolis

How to&Answers:

For creating a game like this you really don’t want to use layouts. You would create a tile engine using bitmap blitting or OpenGL.


You can use the following methods, for rotation of view,

Note: All the above are Since: API Level 11


If you dont know much about making a game the read this book


It will teach you EVERYTHING you should need to know to do what you want. It also sets up OpenGL ES for you so your app will be nice and smooth

I really would suggest OpenGL, using the Canvas class will not only be slower but it is going to be limited as well


For a game like this, you should really implement your own graphics code instead of relying on the standard Android layout components. There is no way to rotate an Android layout by 45 degrees. There are essentially two ways you can go about this: you can either use Canvas and draw your graphics using primitives and bitmaps, or you can go with the more powerful OpenGL implementation which has a steeper learning curve but may have better results.

You can read more about 2D graphics on Android here:

And more about 3D graphics here:

Bear in mind that OpenGL is more suited to real-time games, where the game needs to keep up a good frame rate. If your game is a strategy or turn-based game, you could probably get away with a simpler Canvas-based implementation. I’d advise you to check out the following classes in the framework:





Have you checked out this Android Game Engine? It’s called AndEngine – while I have not got to play with it much – it has the functionality to have a “topview” type game as in say Diablo II.