I want to create a shape like this image.
I searched a lot for drawing on canvas with different shapes.
I didn't got anything on StackOverflow or Google.
Here is the link I referred
In this tutorial I got to know how to use the curves with canvas.quadTo();
Android How to draw a smooth line following your finger
How to draw a curve according to a control points list that has more than 3 points
//here i got to know about canvas.cubicTo() method which will give curves from start point to end point with middle point.
I don't have any code to show, so, I need to start from scratch.
I need this to be created as ViewGroup, so that I can add 1 View to this ViewGroup. If I add another View into this ViewGroup then the background should look like this.
Related
can someone please give me advice or instruction how to create custom view, which draws two circles with different (or maybe same) count of arcs, and the most important, enable rotating each circle independently anti/clockwise by touch move? But no moving on center hole.
I think image describe it best
rotating circles
I needed something like this and I can't find a component so I implement one.
A custom view that uses Canvas in onDraw method .
For each wheel you can add a list of String to show in each section and a list of Paint to paint that section .
https://github.com/mehdi-azizi/Nested-Wheels-View/blob/master/NestedWheelApp/app/src/main/java/com/ma/nestedwheels/NestedWheelsView.java
Once again I started to experiment with Android things. I'm trying to create a small simple game, which uses a hexagonal board. I know the math behind the hexagonal calculations, but the problem is how to actually implement such board in Android?
At first I thought of using a grid view where every other line is displaced by half step and then use these square grids as my board and just draw a hexagonal shape over the square boxes. However, the regular grid view doesn't seem to allow me to do that.
So I thought that maybe I need to create a custom view with either hexagonal grid or a custom view with square displaced grid.
I'm not familiar with Android custom views. I read a tutorial about custom views from Vogella's tutorials but I'm still very unsure, if it's even possible to create a hexagonal grid as a custom view.
So any ideas and help of how to create and implement a hexagonal game board on android?
I would certainly go with a custom view for this. When you draw the view, you can have a loop that draws each hexagonal tile in the right place within the view as a whole. This will give you the most flexibility.
I suggest you start by writing a method that determines, for any given point within the whole view, which hexagonal tile it's in. You'll need this for determining which tile was touched, and it will also help with the drawing.
The nice thing about it is that if you keep track of the centre of each tile, then for any given point, the nearest centre point will tell you which tile the point is located in.
I'm a bit confused how Drawable, View and Surfaces should be used in Android. Imagine the following scenario: One main view that can be zoomed (pinch zoom) and on which the user can tab at any point. Everywhere the user tabs I want to add a pre-defined shape and connect all of them by a line.
So I need a zoomable main view which I draw myself in onDraw() method. Then I need to define my drawable in a XML file that will visualize my tab-position and draw that on each of the tabbed position in the view?
I would be glad if you can point me into the right direction how to realize the above scenario the right way.
I've been working on this for a while but can't find anything that exactly addresses my question (at least not something easy to understand).
I have a main layout XML file where I define various layout objects like a Button or a TextView (and I know I can add SurfaceView, View, and view and other things too). I want to draw a shape (in my case it's an arc) in just one of these objects so it doesn't take up the whole screen and so I can position it relative to other things.
(In my case it will ultimately re-draw the arc kind of like a circle with a gap in a different position every time I call a method depending on a value I pass to the method, but that's separate from my basic question.)
I know the answer will have something to do with a canvas, an onDraw method, maybe Paint, probably a view. I have been able to draw a circle from a custom View object by setting the main java file's layout as that View (as opposed to R.layouts.main), but that takes up the whole screen, and I'm unsure how I might be able to have that dynamically draw with modifications.
A really clear explanation or better yet an actual example would just be awesome.
As i see it u need to draw a specific shape on widget and not on complete screen. Try using layer List.
you can refer this link for sample Link
Am I approaching this correctly or is there a better way?
I would like to have various shapes such as lines, rectangles, etc, that a user would be able to re-size, rotate, and otherwise change its parameters by clicking on the shape and dragging.
So far, I've implemented this with shapes by drawing the shape into a view and then adding the view onto a layout. A user can then drag that view.
But is this the best way? By doing this, I am manipulating the view that contains the shape and not the shape itself.
Can the shape be re-sized/moved directly through user manipulation?
The best way to draw shapes in Android is extend class from view then draw shapes in onDraw method also you can resize and move shapes using onTouch method dynamically.
Refer this link,
http://www.kellbot.com/2009/06/android-hello-circle/