Fairly new at android dev, haven't got any code for this particular step yet so ill try give as much detail as possible. I'm trying to make an ImageView object move around the android view/activity, unlike java im not able to use the random generator to translate it onto an x and or y position on the frame, if anyone could point me on the right direction or more importantly have a good idea on how to do this, that'd be great.
Asked
Active
Viewed 1,723 times
1 Answers
0
There is a class in android called Random. And there is a function called nextInt() which can give you a random number. You can also calculate the width and height of your screen using DisplayMetrices so that you can keep the image inside the device's screen. And you can also move the ImageView. See this link.
-
op is asking something different i believe ,cuz he wants to display that image at some random position ! but he clearly needs to take care of the position with respect to the screen ..may be you want to modify your answer ? – Vamsi Pavan Mahesh Jun 14 '14 at 14:49
-
-
good .. but don't you want to give him an example of how would you do that ..like by putting layout_lefto and all so that image will be there on the screen .. ? .Anyways you can leave that to OP :) – Vamsi Pavan Mahesh Jun 14 '14 at 14:53
-
@VamsiPavanMahesh I posted a link for moving the image. I can't write whole code for him :) – berserk Jun 14 '14 at 14:55
-
i think i have edited the question in a way that i understood ..hope that it will be accepted ..so you can write an answer for it .. or i will write by myself – Vamsi Pavan Mahesh Jun 14 '14 at 14:58
-
-
-
@VamsiPavanMahesh :D But you may be right about what he is asking, so you can post your answer :) – berserk Jun 14 '14 at 15:03
-
screw it .. he did not accepted my edit suggestion and is asking the same question again and again .. waste of time – Vamsi Pavan Mahesh Jun 14 '14 at 15:05