How to add custom gesture android studio? - java

So there is my question. I would like to know how to add custom pattern for a gesture in Android Studio, just like: draw a tick to continue or something like that.
Thanks in advance.

I don't think this is possible as you have to use the MotionEvent enum. An example of how this is done is shown here
You'd have to look at extending this or using movement tracking to work out things like velocity of the motion, there's documentation here but it doesn't look elementary.

Related

How to get the touch coordinates of a touch event in HarmonyOS?

I am writing a helper class to zoom an image in HarmonyOS using Java SDK. I want to get the touch coordinates of the dispatched touch, in Android we can use the following code snippet.
MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords();
event.getPointerCoords(index, pointerCoords);
What is the alternative for the above in HarmonyOS?
According to the team, HarmonyOS does not currently have the alternative method for this. But there are plans to support it in the future.
If you just want to get touch screen coordinates, you may can refer to this Docs.
You can take a look at the TouchEvnt.getPointerPosition(touchEvent.getIndex()) section to see if it can help you.

How to create some thing like gmail compose in android app

How I can create some thing like this? Has it any specific name or view? Like red cycle image in below link:
You can create that view using a ListView like its explained there: https://developer.android.com/training/material/lists-cards.html.
You can create the floating button using an oval shape with an image inside and set some elevation. Click here for more info How to create a floating action button (FAB) in android, using AppCompat v21?
Have a look at general Android Material Design Guidelines to get some additional insight for these kind of ui. https://developer.android.com/design/material/index.html
This can be useful for you. I made a "dummy" Gmail UI for show a material activity transition. https://github.com/coyarzun89/FabTransitionActivity

Android app navigation | custom navigation

I think this could be a bit difficult.
I created an coordinate system, to build a game upon it. Since now your are able to move left and right by swiping. Is it possible to allow swipe up/down?
But I think its very annoying to swipe all the time, so I had the idea to add a system like google maps using it (move around by tap and hold).
Is there already a listener or something similar to include this, or does anybody know how to create something like that.
I've already searched around the web to find something... without success.
Thanks for your help.
I've got an awnser myself, just use the OnTouchListener and catch the MotionEvent.ACTION_DOWN and .ACTION_MOVE for example so you are able to always get the current touch position and calculate the difference between it and the start position and animate the map for this values.

How to draw sound in android

I'm creating an app on android in java, very simple, which has a button that on click play a sound.
I want to create a sort of canvas to draw something like sinusoide of music.. i hope i've been clear..
Do you know something about this?
look at this Api Demp it may help u.

Explanation of JetBoy example for dev.android.com?

I have developed many applications for desktop or web in java, but never for android.
What little I have practiced with was weird because I am used to SWING. Since it uses .xml files for applications I was wondering if you needed this also in games?
For example there is a a good example at http://developer.android.com/resources/samples/JetBoy/index.html. I was hoping someone could explain two things for me.
How is the image drawn to the screen?
How do you listen for user input? (Eg. Clicks, drawing, swiping, ect...)
I have made games on the desktop so you don't have to get in depth, but I found it hard to understand the code. (What I was suppose to do special for android.)
(Another way to put it:)
I guess basically what I am asking is how to I draw an image that will in turn listen to clicks and such without adding a button? Or do I need to add an invisible button? Then if I did have to add a button how would I listen for swiping and drawing?
Also I saw some methods like doDraw(), but did not see where they were putting the image so it would appear on the android device.
JetBoy is rather complicated for a beginner, check these simple examples which are based on the same principles as JetBoy: How can I use the animation framework inside the canvas?
Everything is done by drawing bitmaps on the view's canvas and an event which detects when and where the sreen was touched.
I think this will tell you everything you need to know, in a comprehensive, 31 part series detailing the creation of Light Racer 3d for Android.
If you are not going to use any Game Engine ,
basically you extend android.view.SurfaceHolder
and then overide these methods,
public boolean onTouchEvent(MotionEvent event)
protected void onDraw(Canvas canvas)
go through
these articles.It teaches everything you need from the scratch

Categories

Resources