I'm developing an android app that User select an emoticon.
I'd like a nice swipe gesture selection with horizontal scroll.
can i create a horizontal scroll to select emotion.
this is an example
https://www.dropbox.com/s/n298h17r3fs2wvj/scrollswipe.jpg
Have you tried using GestureDetector.OnGestureListener?
http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html
I think onScroll() is just vertical, but I might be wrong; onFling() is definitely horizontal but requires a bit of velocity.
If you haven't looked at GestureDetector, then you should write a simple demo for yourself with it in any case.
On the jpeg it looks like you are after a very specific hook like curve. If that's the case, then you need to implement detection yourself using the lower level, more flexible View.OnTouchListener.
http://developer.android.com/reference/android/view/View.OnTouchListener.html
Related
When using motion layout, I built a simple motion scene which changes a cricle from width/height of 100dp to 1000dp with a duration of 2000ms.
Now I want to know programmatically when the animation is finsihed (Observer/Listener?)
I didn't found any built-in features or blog posts which are solving this problem.
Any ideas?
here some tricky way using transition listener
or use Link
and modify on it as you need
I want to make a view that looks like a weight scale, like the image below:
For that I thought of using a horizontal scrolling RecyclerView with view holders representing each value of the scale and that works fine, but I can't figure out how to make it curved or if it's possible. I want it to be curved to look more like a weight scale. Does anyone know how I can manage to do that?
I'd say don't go with RecyclerView. It's not intended to be used for such purpose and it might be very time consuming to make it work. I think that the best way is to write a view from scratch. You can draw the scale manually using onDraw(Canvas), simple math and a bunch of drawing operations. The most difficult part would be to add a scroller to get the fling gesture working nicely.
This is an open question about Android ListViews, Gestures and Animations.
I'm really not familiar with the gestures in Android, so I'm just looking for ideas and grey matter on this.
Here's two screenshot and a video examples of the effect on what I'm trying to cogitate. Consider taking a look at the video, it's really worth it.
The screenshots are from an iOS open source project found here.
The question is, how would you implement a "listview opening" gesture like the one I see more and more often in iPhone/iPad apps, but for Android ?
Edit 1, idea 1:
Okay first idea, AFAIK the Pinch gesture is somehow like a dragging gesture, so I guess we can get the X and Y coordinates of the two fingers on the screen?
Next, the answer to this question may help, the basic idea is:
Get the index position of the first visible item in the list
Get the index position of the last visible item in the list
Iterate from the first index to the last with the getChildAt function
For each child, call the getLocationOnScreen method to get coordinates of the current iterated item
After that, some comparison between the pinch gesture coordinates and each item coordinates might be done inside the loop to get the two items between which the new row must me inserted.
Performances considerations appart I think it could work, but maybe there's a simpler way to get those two items(?).
Who's next? :)
Update:
Thanks for the tip #rhlnair, I take this occasion to tell everybody that I started to work on this on my spare time and you are more then welcome to help on this.
The project is at https://github.com/arnaudbos/Android-GestureListView. I started two different implementations on two different branches, and would enjoy anybody to create a new branch.
I have something really encouraging in branch "attemp-via-scale-gesture-detector" but some side effects from the ListView.
Come on folks!
seems to be a challenging idea..
i think some of the effect in clear app like dragging a selected row up/down can be taken from
https://github.com/commonsguy/cwac-touchlist
When doing a pinch gesture you have two fingers on the screen and therefore a point in the middle of those two points. That is simple euclidean arithmetic to find that middle point.
Then find as you say the element in the list that this point is above. You mention performance and I do not think this will be a problem. You are iteration a loop a few times and asking for coordinates. I have done much worse on touch events.
If the point between the pinch is above the middle of the list item you create the item above, and vice versa below.
See the section at the bottom where they use a scale listener:
http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
Using the scale listener you can use the scale to find out if you create a new element. If the scale is above (you are "zooming" out) a threshold you create a new element and let the view repopulate from the list adapter.
I am working on an application that can read pdf documents and I am trying to implement zooming and panning on a pdf page.
The page is loaded as a bitmap and displayed in an ImageView. There are also some other functionalities already implemented such as navigating the pages in a document with a bottom custom navigation bar that can be scrolled.
Also, the bottom bar appears when the user taps on the page and disappears with the next tap and when flinging, users should be able to navigate to next/previous page in the document.
All functionality such as the scroll, tap and fling is handled by implementing OnGestureListener in the reader activity and I am trying to do the zoom and pan with an OnTouchListener implementation that is set on the ImageView containing the page.
The code seems to work, however it appears that some of the other events, especially the scroll, are interfering with it which makes it slow.
My question is if there is a better way to go about reconciling everything, since the OnGestureListener is used for the GestureDetector's handling of onFling, onTapUp and onScroll, but I can't find a good way to add the zoom/pan code in one of the methods supported by this.
So, if anyone has some experience on handling all these events for one view or some good suggestions/tutorials on this, I would very much appreciate it.
I'm not sure what you mean by 'some other events such as the scroll make it slow', could you elaborate?
You should be able to perform zoom and pan using onTouch fairly trivially, without scrolling being an issue if you choose to use Canvas. Full implementation code can be found at Touch and drag image in android for scrolling, and http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/1847 for zooming.
It's generally not common to see advanced interactive features applied solely on an ImageView, but that doesn't mean people haven't done it (see How can I get zoom functionality for images? for zoom examples including support for multi-touch or Adding Fling Gesture to an image view - Android ).
Regardless of which way you do it, you'll probably want a GestureDetector in your onTouch function. You should be able to just cut and splice together sections of the tutorials I've linked to in order to get full gesture support + zoom/pan. However, if I were doing it, I would probably just use onTouch with Canvas (since Canvas will give better performance) and use the core MotionEvents such as DOWN MOVE UP for greater control, or if I was feeling lazy, use a GestureDetector for trickier bits like flinging.
I implemented a custom android SurfaceView class which draw (onDraw method) something often bigger than the available device width and height. When the user toutch the screen and move it's finger I need to implement a kind of picture movement with a speed and direction matching the speed and direction given by the user. That part I'm able to do it within onTouchEvent method. But here is my question: now I also want the speed to decelerate progressivly. I think this probably have to be coded with DecelerateInterpolator... Is there some samples or demos somewhere involving a SurfaceView, onTouchEvent and DecelerateInterpolator... ?
I was thinking of a too complicated way to address the problem. Finally found a way to solve my problem here: Smooth scrolling in Android The OnGestureListener simplify all gestures management.