In my application I want use WaterWave effect on custom shape such as below.
I want to change this WaterWave position with percent, for example this percent is 0 to 100.
When percent is 0 show empty, percent is 100 fill this shape, percent is 50 fill half shape and more ...
I search many time in google but just find library for circle or heart shape!
I can't find any shape such as above shape!
How can I create shape with WaterWave such as above image?
Please help me Please help me
I think you should create a custom View and override the onDraw() method to calculate the percentage, then draw a mask on top of that to give the droplet effect. The shape of the wave looks like the sin function, so you should play around with that, so the view percentage is dynamic. Good luck!
Related
Let's say I have an Activity containing a ChartView (blue rectangle)
Now, I want to place another View on top of it that will stretch from the X-axis all the way to the top of ChartView.
I tried to do that by setting the margin-bottom equal to the height of the X-axis (red area), but I don't know how to get its height
How can I achieve this effect? Is there a way to get X-axis height in Android MP Chart? Or maybe there is a walkaround that will have a similar result?
Desirable outcome (the gray area is a view placed on top of the chart):
chart.getXAxis().mLabelHeight returns the height of x-Axis by pixel.
You can get it after OnGlobalLayoutListener, because it is calculated after x-Axis is drawn.
----------Updated Jun 22nd
another way is to use "getHeight() - mViewPortHandler.contentBottom()", but mViewPortHandler is protected, so an extended chart is necessary to provide access to mViewPortHandler
I want to fill the background of multiple size (custom width or height) constraint layouts with this design:
Noticed that the outline border is glowing with fading gold color.
I have tried with the following:
Attempt (A) is using of ImageView tag, but not scalable to custom width and height.
Attempt (B) is xml created. But the border color is not fading, isn't the desired result.
Attempt (C) is using 9 patch file. The border radius and corner radius does not seems correct at all. (Would also like to know reason of this)
This is my 9patch file:
May I know if this is even possible to achieve?
Anyone please help.
I tried to achieve this but I am only able to achieve to fill object (shape).
My requirement is to change text color along with shape filling.
Shape can be filled with percentage like till
10% to 50% = Green
51% to 80% = Yellow
81% to 100% = Red
When Yellow color fills background of ":" in shape, it will change color to "White" which is previously "Yellow". Size of this shape is also dynamic.
What I tried and achieved?
I am able to fill shape with percentage but failed to change color when it reaches to edge of text.
I wrote a custom view. You get this double color effect using Path APIs. But for Android 1+ compatibility, you should use Region API and above Kitkat (19+) you can use just Path API.
Let's go through the concept of how to achieve this effect step by step:
There are three shapes we need to draw - Outline Rounded Stroke + Orange Progress Bar + the text itself
We draw the stroke as it is
But for the Progress bar, we need to remove the text that intersects with it and basically make the text intersection transparent. (DIFFERENCE)
Also for the Progress Bar, we have to show only the part of the rectangle that intersects with the outer rounded stroke path. (INTERSECTION)
And similarly, for the text, on the left side we basically chop off the parts that intersects with the progress bar. And we only show the right side of the text that is orange in color. (DIFFERENCE again)
If you are using API 19+, this is how the critical code snippet looks like:
croppedProgressPath.op(progressPath, textPath, Path.Op.DIFFERENCE);
croppedProgressPath.op(progressStrokePath, Path.Op.INTERSECT);
————————————
croppedTextPath.op(textPath, progressPath, Path.Op.DIFFERENCE);
Lines here and here.
I’ve written a Proof of Concept for this project called Diffre on Github. If you wanna test it out first, all the code is in this repo.
I want to have 3 TextViews that are surrounded with circles as below:
The text views are centered in the circles.
I was planning on using TextView's with backgrounds set to a drawable containing a circle.
However, to position the circle properly I need the radius of each circle.
I tried to use Drawable.GetBounds() and then find the hypotenuse of the boundary rectangle, but this doesn't yield the values I want.
How do I find the radius. Or is there a better way to go about this in general?
Am I stuck just using a custom View and overriding onDraw?
This was a really dumb question. The radius is set to whatever the width or height of the View is.
I have been trying to make a circular TextView. Its a circle in which I want to accomodate whole space above a circular bubble as shown in image below.
Kindly see attached image.
In this image, we have a circular bubble with circular text in it.
I have already tried setting oval shape .xml as background of TextView but still no luck.
Edit:
As text length increase. It must reduces in size to fit inside the circle. This is the hardest part to think about.
You need to create a custom view, extending from TextView probably, setting the circle as background image, and calculate the text width / break the lines manually according to the width of the text.
To calculate the width of a string, see How to calculate string font width in pixels?
Some math and calculations is required of course to measure the available space per line; but I think that's the only way, as there's no standard component out there to do it.
To place the text onto the view, use drawText of the Canvas class.