I'm working on a viewFlipper that switch between listviews, and so far, so good. I launch animations on a onTouchEvent. My problem is that to go in the onTouchEvent, I have to tap on a area empty of component, like if my activity is the last component to ask for the focus.
I want the exact other way around. I want that wherever I tap on the screen, despite of the others components, it launches the onTouchEvent. Must be simple but so far I did worthless research.
Thanks.
Related
I'm creating a HelpActivity above my MainActivity, HelpActivity is almost transparent.I want show to user the place he should touch to do staff, but I don't want finish() my HelpActivity and then let the user to touch that place, I need when user touches the place in HelpActivity the exact place on MainActivity simulate like when user touches it.
I hope you understand me.
I think your over complicating the situation.
If you want to be able to allow touch to pass to a view lower in the Z-axis keep all the views in the same hierarchy (i.e. Activity) - then you will get this behaviour for free rather than using a massive hack to achieve something the OS will do automatically.
OR use something like ShowcaseView
I noticed something strange today and i'm not sure the best way to describe it.
I have two activities (A and B). I'm on A and start a new intent for B. I override the pending transition to be a slow slide up. This part is fine.
When B is sliding up I noticed that I can still tap on the screen where B's buttons would be and use their actions. (example, there is a close button to close B. When I tap on it's destination area it will close B even though it hasn't completely gone up).
My current solution is to disable all of the buttons until the animation is done. This is working fine, however I'd be interested to know if there is a better (more standard) solution. If anyone can explain (and confirm my suspicions) then that'd be a nice plus!
This is the expected behavior. Android is simply animating a transition and not actually moving the views from one physical location to another.
What is the best way to touch two buttons at the same time? I am working on an app that has buttons, like a D-pad and a jump button, to move your character around. Right now I am just using normal buttons and handling them with an OnClickListener. I am having problems when I am running and need to jump at the same time, or if I am running to the right, then want to go left without having to pick my finger up. I know this is possible because it works greats on game like Sonic CD and some others. Any help would be greatly appreciated.
OnClick fires only on release. Instead use the touch event handlers so that when they touch occurs, you get the events. However, note that not all devices have multitouch, and thus not all of them will be able to handle the double-touch case correctly. They will provide touch events, but not two of them. Also note that you may receive multiple "pointers" within a touch event, and will have to decide which is "yours" for each button if that matters.
Good day to all!
I'm trying to implement a voice over for Android (like iPhone), but a specific application (not the entire operating system)
Imagine a screen with six buttons, so they occupy the entire activity, distributed equally in size.
When I "walk" with my finger on the screen, I want to give focus to the button and capture the event when the button has focus and let the focus as well.
Conclusion: As I flick on the screen and if it is over a button, the focus button. if I continue to drag the finger, give the focus to another button without taking your finger off the screen.
Can anyone help me? Sorry for bad English.
I don't think you can use the Android Button class for this, but instead do a custom view, draw six rectangles, and write an onTouchEvent method that determines what sound to play based on where the user's finger is. See the Sudokuv4 example at http://pragprog.com/book/eband3/hello-android for some code you can use.
Well you have to know positions of buttons. You can use basic view functions to get positions (getLeft(), and so on...)
After that you have to implment onTouchListner for Activity. Within you have to check where Event.x and Event.y pointers are and set foucs to specified view. After pointers move from specified view you set focus to false.
I have a clickable TextView with a drawable as its background. I'm looking for the right way to implement a down-state drawable so the background changes when the user presses down. I have been able to almost perfectly replicate this behavior by listening for MotionEvents and changing the background when the user is pressing down.. The only thing that doesn't match up with system-wide down state behavior here is that if the user keeps holding down and moves their finger off the button, the state remains down until they release their finger from the screen... whereas in Maps overlays or Buttons or ListViews or anything else the state immediately goes back to off when the finger moves from the object.
I know there must be some proper way to go about doing this... A nudge in the right direction would be great!
Thanks,
Nick
You need to use a Selector for the background. I'm not sure if there is an official example of how to use Selectors, but I found this site that seems to have a pretty good example:
http://www.craiget.com/2009/03/restyling-android-imagebuttons/
That should get you on the right track.
Edit: Apparently that first link is down, until/unless it comes back here is another example: http://www.mkyong.com/android/android-imagebutton-selector-example/