I was just playing with Android SDK Demos and I found the rotating dialer example which you can find here : Android Rotating Dialer and I'm curious about one thing. How can I set the image to rotate only when I click on image..not inside in or out. I don't want to rotate it if I click at the center (in white area) or outside of the image (again in white area).
Any suggestions how can I achieve this?
Interesting question.
This would be possible by modifiying the code of myOnTouchListener. Just before the switch statement you would perform a calculation to check whether the x,y coords of the touch were outside an inner radius and inside an outer radius.
Some simple Pythagoras and it wouldn't be too hard. If this was not the case then return true at that point.
Related
I my app I have some shapes , I want to fill the specified color in it using touch and gesture. the user finger finger will move inside the shape to fill the color in it , It has starting point so that it should always start from the right corner until it gets the last corner which should be the ending corner.
is the picture link so that you guys can easily understand what I am trying to say.
in this picture you can see the white space of the center shape , I want to fill it with user finger touch.
I have read to many gesture techniques including the gesture builder , but they are free form drawings , so in my app I have to face do following thing
1. To fill under the predefined shape
2. The shape should be filled in a single way , ie from starting point towards the ending point.
3. in other Examples they are drawing on canvas , in my case What should I use ??
Please answer me of my confusions or at least tell me how to do it, Please give me a starting point.
I am interested in implementing a user interface navigation control mechanism based on a wheel shaped device (or pie chart shaped or circle shaped) in my Android app.
I would like only half of the wheel to be visible at any time. That is, only the top half of the wheel should be visible since the bottom half should be below the border of the screen. The user can then turn the 'half wheel' to show options hidden by the screen border. The visible top half should then be divided into three parts like a pie chart, so the user can press either one of them to invoke some action. The following pic should explain (it is an example with seven (A-G) options).
http://imgur.com/lNu1F
The rotation itself should not be hard, but I am having a hard time understanding how to position the wheel so that half of it is outside the actual screen. I am thinking that loading the entire wheel (but hiding half of it) is best, since that is that graphics I have and it will also allow a smooth animation when the user swipes to show some other options. How can I make Android show the wheel in this way?
Also. Any comment on how to implement the 'swipe along the wheel shape' would be appreciated.
Thank you.
So for the wheel - you are hving trouble knowing how to position the wheel because you are using XML to align you objects and would like to use something like "Align Object Center To Bottom" which does not exist.
Here is one approach that might work fine: Mask the wheel view.
Is it possible to mask a View in android?
As for swipe the wheel along, I would register the wheel to take touche events, and use only the horizontal componenet of move events to apply to the rotation of the wheel. This setup is common in audio software that uses knobs.
However if you want to have it stick to the users finger in a more realistic fashion, you will need to do the following:
When the user first touches the wheel, calculate the angle from the wheel center to the finger.
Every time the finger moves, check the angle from the wheel center to the finger - and rotate the wheel the amount that the angle has changed from the last touch event.
The formula for getting the angle between two points is this:
Float angleInRadians = Math.atan2(point1.y-point2.y, point1.x-point2.x);
I have a dial-or image as shown in which whenever i move the finger in clockwise manner the part covered of sub ring gets yellow in color.I tried to apply this scenario through gesture overlay but do not serve the requirement.
Any idea is welcomed.Please assist me and thanks in advance.
I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?
I wrote something like this that allows curved animation, you can see the full answer (and working code) here: Problem to achieve curved animation
It shouldn't be too difficult to either chain a number of those together, or modify the algorithm to use a cubic (or higher) function to produce multiple curves.
Only caveat is that because of the bezier curve, there is no guarantee the path will actually travel through the middle point you give it. If this is a problem again you could easily replace the bezier algorithm I use in the above example with something more suitable for your needs.
Check the sources of TranslationAnimation where the translation is done. Then build your function that maps the sinus function on the line from start to end. You could start with setting a horizontal line of with length dist(start,end) starting at (start), mapping sinus on it and then rotating it around your starting point.
i am developing checkers application for Android. I have drawn on Canvas gameboard and tiles for each side, also I have made selection of tiles by D-Pad. But what about, Android phone doesn't have D-Pad? There must be a way how to do that in touch (I touch a tile - it is selected now). Do you have any ideas?
Thanks
image of my Gameboard can be found here - http://img171.imageshack.us/img171/7814/checkers.gif
Another (easier?) alternative is to use Android's standard Button/ImageButton. You can customize its border and content, if you don't want the default border to show up.
The standard Buttons works with both touch and D-pad; so you can cut the amount of coding you need to make tiles that behave properly under both situations.
Store tile locations in a 2d Array. On the finger down event, check the event location against each tile. When you find the tile that was poked, select it.