In this above picture, all circle is a view with three text view. These views will be added dynamically. It will be 4 to 15
And at the below circle view with three text view will be fixed.
All circle will be connected with the end one. and will need to draw a line with one another. And at the middle of the line there will also be a textview.
How to implement this custom view. Any kind of will be appreciated.
Related
I'm trying to draw some text on path using the canvas in Android. I can successfully get the text to draw on the top oval line. What i'm struggling to do is make sure that the text is centered.
The problem is that while i can measure the text before it gets drawn round the top line of the oval, i cannot measure it after. This makes estimating where the text should be drawn on the top oval line problematic as it's always a little bit out. This is because when i measure the text to be drawn initially it is measured in a straight line and not as presented on the top line of the oval.
I've tried applying setTextAlign(Paint.Align.CENTER) but this makes the text get drawn about 3/4's of the way round and not what i want.
Does anyone have any ideas how i could calculate the point to draw the text so it is drawn dead centre of the top oval line or any alternative method that may help?
This has to be drawn using the canvas. It can't be done using XML TextViews etc.
Thanks.
You can check how this library done it: https://github.com/amulyakhare/TextDrawable
Its using the same approach. But for multiple lines its almost impossible, theres an issue on this library where me and other developers tried to implement it, and we end up using just xml (a round drawable as a linearLayout view background and one textView inside it).
I want to place some (a variable number of!) buttons in a circle around a button in the center. It should be flexible enough that I can easily add one button more in the circle or remove one.
I'd also maybe like to add some animation in the future: the buttons should appear from one side and then circle around the button in the center.
It would be extremely easy to implement but android somehow doesn't allow to set absolute positions.
I mean I can easily calculate the positions where the buttons should be on the circle but how can I the place them there?
By the way, I don't want to add the buttons dynamically they are already on the view (wie View.INVISIBLE).
thanks for your help
As of right now if I have a line chart value that is straight horizontal or vertical and happens to be the exact value as one of the grid lines, then it becomes really tough to see. Is there any way to change the Z order of how things are drawn such that everything draws over the grid lines?
No, there isn't such API.
However, you can play with the colors, for instance set some transparency level of the grid lines color, axes color.
I've got a GridView which is displaying a calendar. I need to draw some fat lines (about 1/4 of the height of a grid cell) across multiple 'days', and possibly across multiple weeks. I may need to do two or three of these for any given week.
Each line across the cells of a week will need to have some text in it as well.
Since the lines need to cross grid cells I though perhaps I could get a Canvas for the GridView and paint on that. But I can't find a way to do that. Since the lines cross multiple grid cells it doesn't seem useful to draw the line in a particular cell and try to line it up with the previous cell. And I have to do this dynamically, I can't set it in the layout.
I'm open to ideas about how to make this work. Anyone?
If you want to do any additional drawing on top of the GridView content:
Override dispatchDraw(), which hands you a Canvas to draw on.
Call super.dispatchDraw() to draw the normal content first.
Use the Canvas to add anything additional you feel necessary.
HTH
I am trying to create a watermark text to my custom view, but the problem is when I scroll the canvas, I am unable to determine the exact co-ordinates of the screen's center.
I tried tracking the onTouchEvent and getting the co-ordinates, but still it is not smooth, it appears on touching the screen during scroll and not always centered.
Is there any way to keep a drawtext out of the scroll?
You can use a framelayout which has to layers. The base one will be the view which scrolls and the top layer will be the textview that has a gravity center. In that case the textview will not be scroll when the base view is scrolled.