Android Question Dragable Angle Line - How?

barx

Well-Known Member
Licensed User
Longtime User
Please see the video below. Des anyone know of a current custom view / lib that can produce the angle line (the one that moves in the vid).

If not, how on earth would I go about creating such a view. I've looked around the forum best I can and also looked on android arsenal to see if there was anything on there to wrap. No joy yet

Thanks

Link --> https://dl.dropboxusercontent.com/u/53092305/Line Angle.mp4
 
What is it for ?
Enter and angle, display an angle or both ?
This can be done with a Panel and Canvas.
Then it depends on what you need or want a CustomView or only a routines doing it with the number display or not.
Then do you need a 360 degree turn or less ?
 
Last edited:
Upvote 0
Is the Attached project what you are looking for?

It's a CustomView, you can add it either in the Designer or in the code or compile the project to a library and use this one.

upload_2016-3-19_16-30-29.png

OffsetAngle = 0

upload_2016-3-27_14-0-35.png

OffsetAngle = 90

I think it's a good example that shows how to make a CustmView.

You can of course modify it to your requirements or needs.

The project needs B4A version 5.80 to compile because of the use of CustumView Custom Properties.

EDIT: 2016.03.27
Added a new version AngleView1 with an OffsetAngle which rotates the reference line.
 

Attachments

Last edited:
Upvote 0
What is it for ?
Enter and angle, display an angle or both ?
This can be done with a Panel and Canvas.
Then it depends on what you need or want a CustomView or only a routines doing it with the nubmer display or not.
Then do you need a 360 degree turn or less ?


What I am hoping to do is overlay the view over a camera preview so that the user can measure the angle of real life objects by lining the 2 lines up. So, 1 will be fixed (you line that one up first) the drag the other line as required. Then the angle will be displayed....
 
Upvote 0
Is the Attached project what you are looking for?

It's a CustomView, you can add it either in the Designer or in the code or compile the project to a library and use this one.

View attachment 42547

I think it's a good example that shows how to make a CustmView.

You can of course modify it to your requirements or needs.

Taking a loook now.
 
Upvote 0
Is the Attached project what you are looking for?

It's a CustomView, you can add it either in the Designer or in the code or compile the project to a library and use this one.

View attachment 42547

I think it's a good example that shows how to make a CustmView.

You can of course modify it to your requirements or needs.

Any chnce of sending the .apk?

Sorry to be a pain but i'm not running the latest at the moment, License run out a few months ago and having not done any coding for a good while I haven't renewed it yet :(o_O

Running 5.20 and it won't compile.
 
Upvote 0
Oh my gosh @klaus, that is absolutely sexual. Guess i'm back into b4a.

That is exactly what I wanted.

I better get in touch with @Erel, see if he can do me a deal ;)
 
Upvote 0
@klaus

Before I start making a mess of your nice neat code. Is there a simple way to rotate the whole thing + 90 Degrees?

If it isn't a 2 second job, just say. I am studying your code anyway to learn the process so will eventually figure it out.
 
Upvote 0
Hello,
is it possible to set the center point by clicking on the control or having the control hidden click on the screen and then take the value and use it as center point on the control and then make it visible?
My second question is after having set the center point, is it possible to click on a second point on the screen and use the angle created by the line between those two points and the screen horizontal and use it as offsetangle?
Thank you in advance.
 
Upvote 0
Sure, it is possible.
Thank you for your response.
I was thinking to send the X and Y from a touch event to the angleview's InitDrawingVariables Sub. Do you think this is the correct approach?
About my second question I have no idea yet. Does something come to your mind?
 
Upvote 0
Well, in my previous post, I couldn't resist, just giving the short answer to your question: "Is it possible":).

It may depend on what exactly the usage is.
If it's similar to the explanation in post#5.
I would do everything in one new CustomView.
First, define two transparent panels covering the image.
One to show the center point and the reference line and the second one for the dynamic drawings.
one for the center point and the reference orientation and the second one for the dynamic cursor..
Define a State variable to know in what stage you are.
Then, in the first Touch event memorize the center coordinate in ACTION_UP and draw the point onto the first panel.
Increment the state variable.
Then in the second Touch event, show a rubber line to define the orientation, memorize it and draw it onto the first panel.
Increment the state variable.
Then in the third Touch event, show a rubber line to define the angle and memorize it and leave the CustomView.
Add a function allowing to erase the current data and begin again.
 
Last edited:
Upvote 0
Back
Top