0

Alright, I am sure this question is asked before and I searched the forum but I couldn't find exactly what I want. In a nutshell, I want to be able to rotate an imageview and still this rotated image is clickable (the new space it occupies)

I am creating a card game, and I want the player to be able to see his cards like how pople normally hold their cards in one hand (rainbow style). So currently, I have each card being an imageview and they are just best each other. How can I rotate each imageview by a certain angle? I don't want to use rotate animation as it does not change the x/y positions of the image after rotation which prevent from getting a touch on the corner of the card any help? Thank you

Snake
  • 14,228
  • 27
  • 117
  • 250
  • not an easy question since view boundaries are rectangles. So you certainly need to process touch events yourself and map them to your rotated cards. So you'd have imageviews which are bigger than the cards overlapping each other and holding the rotated images. I think that will get messy very quickly. Especially if you want to add animations. I think that a game framework like AndEngine would be the right choice for such a project. You get sprite handling, picking and much more. – Renard Apr 18 '12 at 17:51
  • Which API level are you targeting? – Joseph Earl Apr 18 '12 at 17:56
  • Thanks for the engine, it is kinda too late for me now as I have many things setup and just this was remianing.. I will consider it for future project – Snake Apr 18 '12 at 20:29

1 Answers1

0

Here is a question about rotating a TextView. You'd have to override the onTouch method as well, but it should be enough to get you started. Rotating a view in Android

Community
  • 1
  • 1
slayton
  • 20,123
  • 10
  • 60
  • 89
  • Its good answer, I check it out but people were complaining that it does not rotate the content (text) and that would be a problem as I want my image to rotated .. or did I miss something? Thanks – Snake Apr 18 '12 at 20:33
  • If you override an imageview and rotate the canvas prior to calling `super.onDraw()` it will draw a rotated image. The commenter in the question I linked to wanted the textview rotated but *not* the text, i'm not sure why though – slayton Apr 18 '12 at 20:39