Hi I am new to Android and I am currently experimenting with some Android features.
So I wanted to find a way to add flexibly add slices to a disk image (could be a pie chart or a roulette wheel). I have done some research on this topic, Drawable Resources | Android. If I wanted to insert a slice dynamically, I think the InsetDrawable method would best suit my situation. So that a bitmap would not be recreated every time the image changes. I have also gone over some tutorial on how to change Cartesian coordinates into Polar coordinates Android SDK: Creating a Rotating Dialer. I was hoping to combine the InsetDrawable method with the polar coordinates to achieve this function. So I was wondering if can anyone tell me whether or not my thoughts are feasible?
A sample of the image that I would like to get is shown below:
Instead of having 6 slices, the user could add more elements to populate the disk to make it 8 or 10 slices, or remove slices from the disk.
It would be great if anyone can share a link to some of the related topics or tutorials as such.
Thanks in advance :)
What is that you exactly want? If you want to dynamically add a slice every time you click a button, all you have to do is arrange the 6 slices in the form of a circle in the xml as 6 ImageViews. You will have to make these ImageViews invisible initially. And inside the onClick function of the button you make the ImageViews visible one by one.
Related
I'm currently working on an app that will teach users how to write a foreign character(Character Tracing/Alphabet Tracing) such as Kanji, Hangul, Arabic and etc. I made the characters through Adobe Illustrator and imported it as XML file in Android. The SVG will then serves as a guide to trace its stroke and detect the user gesture, the user should follow the stroke and then it should be filled once it is done correctly else it should display the stroke what user should trace first.
Please see the sample image below:
The red line below is my gesture while the green line shows the correct way of tracing the character before proceeding to the other strokes.
Does anyone here has already experienced working with this kind of projects? Is it possible to do it using native android gesture detection? Thanks in advance
Disclaimer: The screenshot below is from the app Japanese Kanji Study, developed by Chase Colburn
If I were you, I probably wouldn't use SVG <path> elements. I would use a sequence (array) of points (ie the equivalent of an SVG <polyline>). The points should be close enough together that they look like a smooth line when drawn. Or you could apply some smoothing when you render them.
The advantage of the points array is that it is much easier to find the closest point to your touch location, than it is to find the closest point on an arbitrary <path>. And when you are "tracing" with the finger, you just need to draw a line through all the points up to the one closest to your touch location.
Obviously for most characters you would actually have two or more point arrays. But you would just work with each array in sequence.
Actually just take a look html and get some ideas. In html you can give coordinate area inside a image map and make it clickable. This following link elaborated what i am trying to say.
So after giving area, you can make order like 1 area 2 area ... n area. After that you gonna need first area clickable just give a flag, if there flag = true, then change background color when it is touched. When first area touched you make following area flag to true. It is all up to you. One of the solution. But main thing is in xml you can create MappedImage with co-ordinates
I' m new in anroid programming and i want to create sequential translate animations. I have ten images, what i want is as follows:
I choose image randomly and create translate animation for this image. Also, same image can exist more than one times on the screen and these translate animations shouldn' t wait other animations end. In other words, more than one animations should exist on screen at the same time.
I fight with this on two days and still I could not do what I wanted. If you give an idea or a piece of codes, i will be gratefull.
Thanks in advance.
I need to develop an app to design a watch, as a beginner to android, i'm in need of two suggestion,
1) How to arrange the tick (for each hour in a watch) circularly?
2) Am i go with custom layout to arrange the ticks and labels? or use the same logic inside a method itself?
I hope the question is clear, Thanks in advance.
Joy Rex
Reading your question ther very first thing came in my mind is
GaudgeView
You may need to customize it for second and minute hand. But you will have lot more clear idea with this widget to start with.
Its extends the View class and works on Canvas.
He has provided some customizations options too.
How to arrange the tick (for each hour in a watch) circularly?
I would recommend using an image for that because it would be easy and faster in rendering it on the canvas rather than drawing each tick on the canvas, you can create the image in Photoshop or your favorite editing tool.
Am i go with custom layout to arrange the ticks and labels? or use the same logic inside a method itself?
Yes you need custom layout, if you are planning to implement animation of the big and small hand of the clock you can can again create an image for small and big hand and draw it in canvas and for animating you can use the matrix.postRotate from the Matrix class to rotate the arms of the clock each second,minute,hours.
How Android screens go beyond the simple controls that have Android, look at this for example.
How come so that each key responds independently? Is it a single image, several or a drawing?
How to put each circle in the specific country? What if I want a country to be selected?
You can make your own controls by subclassing a view and overriding it's methods. The onDraw method gives you a canvas where you can place just about anything. Check the official android API or this post to get your started.
For the first image, my guess is that it is one image and the position of each click is translated to the corresponding key on the piano. The second image might also be a single image with separate overlays for each country and circle to set the desired color and place the numbers (that's what I would probably do, but it can be done differently).
If you require more flexibility than fixed images, take a look at creating 2D graphics.
I'm fairly new to the Android platform and was wondering if I could get some advice for my current head scratcher:
I'm making an app which in one view will need an image, which can be scrolled on one axis, with a load of selectable points over the top of it. Each point needs to be positionable on the x and y (unlikely to change once the app is running, but I'll need to fine tune the positions whilst I'm developing it).
I'd like to be able to let the user select each point and have a graphic drawn on the point the user has selected or just draw a graphic on one/more points without user intervention.
I though for the selectable points I could extend the checkbox with a custom image for the selected state - does that sounds right, or is there a better way of doing this? Is there any thing I can read up on doing this, I can't seem to find anything on the net about replacing the default images?
I was going to use the absolute layout, but see that it's been depreciated and I can't find anything to replace it.
Can anyone give me some code or advice on where to read up on what I need to do?
Thank you in advance
This really feels like something you should be doing with the Canvas and 2D graphics, rather than trying to twist the widget framework to fit.