I have some text content in a scrollable container and I want the user to be able to scroll it having the nice effect of it moving according to the swipe velocity and to keep scrolling until the user taps it. (as many applications for mobile touch screens).
I am thinking to combine events to do it. I will catch the swipe to know the direction, have mouse in and out to see velocity and legth of the swipe, and then keep scrolling with a proportional velocity and length until the user taps the screen.
Does my idea makes sense? (I donĀ“t want to do the work and find out it was really simple and I just didn{t knew how)
Thanks in advance
Maria
A scroller will achieve this for you:
<s:Scroller left="0" right="0" top="0" bottom="0">
<s:VGroup>
<!-- Your content e.g. -->
<s:TextInput/>
</s:VGroup>
</s:Scroller>
Click the screen and drag in the direction. Tap to stop the movement or wait till it ends.
Related
In my android app, I have a linearlayout where I put many linearlayouts with images in it. It will go past the screen border horizontally and vertically.
I want the user to pinch zoom in or out and pan around. I tried putting it in a horizontal scroll and vertical scroll, but it wont let me zoom, and I can only move in 1 direction at 1 time, like it wont let me move diagonally.
I tried this plugin
https://code.google.com/p/android-zoom-view/downloads/list
But it won't let me pan around. It only lets me do it on the stuff thats visible on the screen...
Does anyone know how to make this work?
Thanks
The easiest way I can think of is to put your images in HTML and use webview to display it.Webview automatically handles zooming and panning of content.
I see that the latest version of GMail has a slider. Basically, I can slide an entry to reveal what's behind it. I have been needing to do the same thing. I have tried to use onTouch to track displacement, etc. But my approach is very jiggery and the actual scrolling lags quite a bit. Does anyone know how to accomplish what I seek with horizontal scrollView or such? Or better yet, how GMail is doing theirs?
An important aspect of mine is to have some snap action. So if the user has scrolled to greater than X, I am to continue sliding to the left for her, for example, until the front image reaches the left edge.
Or could I use a navigation drawer to accomplish this? I don't think so as yet, but maybe someone has done it. I have been working on this for about a week now, and all my attempts are not quite there.
There are a couple Dev Bytes that discusses how to implement this from scratch (see "DevBytes: Animating ListView Deletion" and "DevBytes: Animating ListView Deletion: Now on Gingerbread!"). Alternatively, you could look at SwipeListView.
I have a ViewPager inside a header of a ListView, and I noticed that, when you're swiping the viewpager, if the finger moves a little bit on the Y axis, the event gets canceled (I guess it's intercepted by the listview?).
The only way to swipe a picture, is to just slide your finger through few pixels, since there'll be less probabilities that you're moving your finger along the Y axis.
Is there a way to make the listview not to intercept the Y axis events in case they happened in the viewpager? I don't even know if this is what I need anyways.
Thanks a lot in advance.
You can try to intercept touch event
Take a look at this post Android - ViewPager scrolling resets
hope it helps
good luck
I am an amateur (desktop) programmer but I want to get into phones. I have some ideas for apps but the touchscreen and it's inputs confuse me....
I know that touchscreens can accept multiple points of touch. For instance zooming in you take two fingers and you bring them closer.. and for zooming out you do the opposite.
Here is my problem though... I've never seen functionality with any phone app on any phone (I use windows phones and android phones) where.... the input on touch is multiple points but it doesn't begin at the same time.
For the sake of illustration I'll make an example. Suppose you have a mini browser on a phone... and it has a vertical scroll bar... and a horizontal one. What I want to do is be able to scroll down... and WHILE i am scrolling down also scroll the horizontal one so i can move the page left or right. So a few seconds after I touch the screen and begin moving the vertical scrollbar downwards or upwards... i want to use a different finger and touch the horizontal scrollbar and move it as well (at the same time).
Is this even possible? Are there certain hardware or software limitations preventing something like this?
You are mixing up gestures and touches. Gestures are touch behaviors, such as...
Two fingers placed at the same time that grow apart from each other means zoom-in.
Tap and hold means context popup.
Tap and drag equals scroll.
You can cancel these gestures when your app doesn't follow these conventions. For example, Angry birds doesn't scroll if you tap and drag on a bird, but it does if you do it elsewhere on the scene.
The default state of gestures is to not detect additional touches while you are performing a gesture. if you scroll and introduce a second finger to click on a button while still holding the scroll finger, nothing will happen. I'm not sure if you can override this behavior (and I don't think it's a good idea either).
Touches, on the other hand, allow a certain amount of simultaneous touches depending on the device. When a touch is not a gesture you can start a second or n number of touches after the first one starts.
You can try this out yourself at http://raphaeljs.com/touches.html.
Now, going back to your example: it depends on how it's implemented. If you are using the OS gestures (tap and drag anywhere) then no, you can't introduce a second finger to drag horizontally, you'd use the same finger used to scroll vertically (panning with a single finger). But, if you have actual scrollbars (like those in mouse interfaces) then yes, you can implement the kind of interface you are describing.
Yes its possible and it depends on the phone but since most android devices and all WP7 devices got multi touch it shouldn't be a problem
Is it possible to detect every pixel being touched? More specifically, when the user touches the screen, is it possible to track all the x-y coordinates of the cluster of points touched by the user? How can I tell the difference between when users are drawing with their thumb and when they are drawing with the tip of a finger? I would like to reflect the brush difference depending on how users touch the screen, and would also like to track x-y coordinates of all the pixels being touched over time. Thanks so much in advance for any help.
This would be very tricky primarily because every android phone is going to behave differently. There are some touch screen devices that are very, very sensitive and some that are basically "dull" by comparison.
It also sounds more like you are wanting to track pressure - how hard is the user pushing on the screen - which is actually supported on android devices.
I think some of your answer may be found by monitoring all of the touch events - in practice, most applications ignore a great number of events or perform some kind of "smoothing" of the events since there is literally a deluge of touch events when the user is manipulating the screen. Doing this may negatively impact your applications performance though.
I would recommend that you look into pressure sensitivity and calculate a circular region around the primary touch point based on pressure, then build your brush around that.
Another idea would be to incorporate more of a gesture approach to what you are trying to do - for example, visualize touching the screen with the tip of two fingers together (index and middle) and rolling the middle finger around the index finger or simply moving the middle finger up and down in relation to the index finger. Both fingers would be moved together for painting. This could be used to manipulate drawing angle on the fly or perhaps even toggle between a set of pre-selected brushes or could change brush size on the fly as you are painting.
Some of the above ideas I would love to see implemented - let me know when you have your app ready.
Good luck!
Rodney
If you have a listener on your image it will respond that there was a touch within that bounding box, basically.
So, to get what you want, you could, but, I would never do this, create a box around every pixel, or small group of pixels, and listen for a touch.
Wherever you get a touch, it may fire off an event, then you can react accordingly.
I can't think of any other solution that will give you each pixel that a person touched, at one time.
You may want to read up on multitouch though, as there are some suggestions in here that my help you:
http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
If you're looking for a way to get your content view as a View after Activity#setContentView(int), then you can set an id on the outer-most element of your layout:
android:id="#+id/entire_view" and reference it in your onCreate() method after setContentView:
View view = getViewById(R.id.entire_view);
view.setOnTouchListener( ... );