I am trying to make an android app and I can't seem to find anywhere how to make a simple activity where a circle shows up when anywhere on the screen is touched. It doesn't have to link with the coordinates with the click, just a circle in the middle of the screen. I have the frameview and everything set up, I just need to figure out the circle class. Any help?
Use Touch events to get the touch points of x and y value.
refer this link
use canvas to draw circle.
refer this link
This tutorial is kinda old, but should get you most of the way there...
You should use a SurfaceView with a drawable at the place where screen is touched.
Refer to this sample which does something similar
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/BouncingBalls.html
Related
Assume that we have a shape on black screen such as:
Blue shape on black
I want to click to this shape with mouse and want that shape's color change. For example, after clicking:
Gray shape on black
I know I can do it with shape detection and with a mouse click event or just changing matrix's values. I tried them but these two solutions are a little bit long for my project. I am just looking for a simple OpenCV method that I can do this operation much more efficient.
Maybe some function which can do the same job with Photoshop's "Magic Wand Tool" can be useful. I searched on internet but I cannot find any solution so I want to ask here. Again, good to remember, I can implement the solution but I just need a method in some framework.
I am developing one simple game in which i have encountered one small but important issue.
I have implemented absolute rotation in my logic.
When i start rotating an object when the object does not have any rotation , it works fine and i can rotate as in any direction without any problem as shown in the following link.
Initial Rotation Video
Now the problem arise when the object does have some rotation , and why i try to rotate in one of the direction , instead of being rotated in desire direction the rotation always starts from initial rotation as shown in the following link.
Rotation issue when shape has some rotation
I think the video shows everything , still if you have any questions please ask me.
I think the problem is , there should be a relative rotation in the direction of mouse pointer from whatever circle is selected .
Now about My Logic,
in mouse press event i just checked
Mouse Press
Whether the shape is selected on the canvas , if yes
if one of the four circles contains mouse point if yes
then initiateRotation
Mouse Drag
Using Vector Maths
I update the motion according to mouse points ,
calculate rotation angle according to the following method
Math.atan2(rotationVector.getY(), rotationVector.getX());
and apply rotation on this shape.
Rotation Vector i get from this class
Vector Rotation
I called above class startMotion in mouse press and updateMotion in mouse drag event.
What am i missing or doing anything wrong ?
We need to see some code to be able to help you out. It looks like you reset the rotation, whenever you initiateRotation, and then the object quickly rotates in place, according to your mouse position when you drag.
I want the user to be able to change the length of a cylinder by clicking-and-dragging his mouse. How should I start on this ? Any form of help would be great.
Check out the example code here. The basic idea is:
Use mousePressed() listener to detect a mouse press.
Use Java3D picking API to detect if mouse press intersected shape.
Use mouseDragged() listener to detect amount of change and update your shape accordingly.
Working on a project that requires marking oval areas on a map. is this possible? has anyone done this before? Searching around I found lots of refrences of how to draw projected circles , but not ovals. would appreciate any insight or help. Thank you
Turns out it is!
I created an ItemizedOverlay which draws the ovals i need using the project method to translate my geopoints to screen coords.
My issue now, and i hope someone has some insight, Is it possible to create an ItemizedOverlay (or some other kind of overlay) that DOES NOT draw an icon.
In my case i want to draw the ovals on the map but i dont want a default icon to be drawn.
currently the ovals are being drawn and the default icon is being placed at their center, the default icon provided to the itemizedOverlay constructor.
I have tried constructing with NULL as default icon but it provokes a NULLpointerException.
thank you.
In order to solve the second issue metioned above, I created an empty Drawable (extended Drawable and left everything empty), and instance of this class is sent as the default marker, thus making the default marker actually empty.
Works as expected.
So I am trying to draw square over live CameraPreview.
I followed camera instructions on developer.android and I got CameraPreview class set up.
I was wondering how could I draw a square on top of the live image.
Something what we can see in face detection on cameras. I wont use it for face detection but same idea.
I have CameraPreview object that i place in my camera activity. Now any suggestions on how to go about learning about this or if you know of any code sample for it.
That would be great. And I am looking to do this in API 10. Not 14 which supports it through sdk.
This is what my current camera app code is based on http://developer.android.com/guide/topics/media/camera.html
Thanks
Put your SurfaceView (which you need for the camera preview) inside of a FrameLayout. Then, you can put that square image right on top of the camera preview.