I want to create Custom vertical progress bar with non linear background
In previous implementation I used skin composer , but as I know it works perfect with simple regular shapes (the knob part resize on the all background image so it looks bad in my example ). I also try to hack using several layer behind the progress bar, but for this case the background behind progress bar is transparent.
I suppose this solution can solve my issue but unfortunately I dont understand how can I implemented that solution.
I also try to crop the inside part (that reference), whenever the progress is changed but I dont think that is the best solution (also the increase/decrase animation cannot be simple enabled )
Could you draw the full red progress bar and then load peices of it until it fills up the whole thing?
Here is a way to get pixels from a png image and you could wirrite your own parser:
How do I read pixels from a PNG file?
Or you could search Google for how to get peices of a png or bitmap.
Related
I would like to design a layout containing an imageview and a background view with two special effect. First is where the main imageview gets transformed with faded towards the vertical edges and second is a background imageview with a blurred effect like the image
The result that i am able to achieve
I saw this post for my first effect and currently using it, but it does not work when I change my phone into dark mode so I am not getting a perfect solution.
And the second special blur effect that i am able to achieve is far way different from what i want to achieve. The required blur effect has some hardness of the different shades of color and mine one is quite smooth. For my blur effect I am using the below code and I am using the library Fresco for my image.
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imageUrl))
.setPostprocessor(new IterativeBoxBlurPostProcessor(60)).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(backgroundImage.getController())
.build();
backgroundImage.setController(controller);
Can anyone please suggest me any good solution or any good library for it or some code sample that can help me to achieve what I want.
The point to note here is the blurred background is an extension of the image itself. So if the left side of the screen has a purple hue the blurred region at the top left will be purple as well.
YOu can use a library like Blurry where it blurs the contents of the screen and then set that as a background. You can control the amount of blur you want.
Once you get the blurred image set it as the background of the container layout and set the picture in front
eg:
val bitmap = Blurry.with(this)
.radius(10) // make it more if you want the lue to be more
.sampling(8)
.capture(findViewById(R.id.right_bottom)).get() // get the view you want to blur
imageView.setImageDrawable(BitmapDrawable(resources, bitmap)) // set the value to the background
I've been trying to create a bar chart/ loading bar where the text is half one colour and half one another and have been struggling to come up with a simple way to tackle this. My ideas thus far have revolved around creating both bars in their complete state and then having a pair of 'selective transparency' views which would show the respective halves to create the effect.
I've been unable to find how to do this selective transparency/ opacity view. Is this possible? Is there some other blindingly obvious way to achieve this effect?
Here's a quick drawing of what I'm trying to achieve.
For anyone stumbling across this, I managed to solve this by using setClipBounds. I did it by creating two textviews of the full size, one with a coloured number and transparent background and the second with a white number and coloured background. Then setClipBounds is applied to the coloured textview as follows -
textview.setClipBounds( new Rect(0, originalHeight*(1 - progress), originalWidth, originalHeight);
Here, the variable progress has a value between 0 and 1. The Rect has to be defined relative to the view, not relative to the screen.
This exact setup achieves an effect something like this, but it could easily be changed to a horizontal bar or whatever else is required.
Somehow misinterpreted the question. The best way to achieve this would be to create the images and set as background to an imageview instead of a textview.
You could just use a LinearGradient
With the parameters colors and positions you can indicate the loading progress.
You can use the gradient when you override the onDraw Custom Drawing
I am currently working on creating a custom progress bar and have so far managed to get the correct image I want to display, however I am trying to customise it so that it fill the white space within my drawable from bottom to top (bottom being 0 and top 100). I am using xml layouts.
I am not entirely sure if this is possible, the image I am trying to fill is;
Any guidance as to whether this is possible or if there are any libraries I would use that would be much appreciated.
I am creating a reference app which has a navigation bar at the top and the information, in the form of an ImageView, below it surrounded by a ScrollView. I have worked out how to change the image when the next button is pressed. I noticed this being implemented on the below app. I am able to get all the programming working, but I am not to keen on visual editing.
http://media1.android-apps.com/images/pname/com.ninjacoders.mcanary/image1.png
What should the dimensions of the Image be in Gimp?
How would I go about creating customs home screen buttons, and what dimensions should I use for them?
Any further advice on how I should do this would be greatly appreciated.
From within GIMP, you should zoom enough your image - and work with the "pencil" tool, and the "pixel" brush (the one brush right after the pepper brush - they are sorted alphabetically) - this will allow you to proper edit pixel-art images.
You can use teh colorpicker and create a new palette resort to let it easier to pick the few grey tones you are using.
To get to know the exact dimensions, one of the tools in GIMP's toolbox is the "measure" tool - use it to get to know which icon size you need.
As a final tip: do your work on this larger image, and draw the icons you want in separate layers - whenever an icon is done, crop its layer using the crop tool, with the option "crop layers" on (else it will crop the whole image) - and then drage the thumbnail for the image layer containing your icon from the layers dialog into the toolbox - this will create a new image consisting of the icon alone (and is a quite faster workflow than copy + paste as new image).
I have to create a custom component on my JFrame, the Component will show the storage status of that user, the storage will be in percentage.
I need to create something like this:
I tried a custom JLabel to create a label and then coloring that label from left to right, but I was unable to create a cloud shape Label and then filling that label according to a variable value.
How should I do this and what is the best way to do it?
One time I thought I should use series of images to show the status of user storage.
Thanks!
I think you're going to need to use an image mask (examples here and here) if you are to replicate that cloud exactly.
The process will require 2 images:
The cloud outline (the blue parts)
An image mask is the shape of the cloud, probably black outside and white inside
Then your drawing process, which you'll have to do each time the % storage changes will be:
Create a new buffered image
Draw then green fill bar in the style you want (e.g. slanted as in this image)
Copy the image mask over this
Draw this new image to the screen, with the mask applied as described here
Draw the cloud outline image to screen
That's going to take an hour or so for you to put together, so I'm not going to do it for you. Have a go, and if you run in to problems (or don't understand anything I just described) then ask about that specifically.
You can use GlyphVector#getGlyphOutline() to get the shape of a Unicode character like ☁ \u2601 and fill it with a GradientPaint.
You can do that with a JLabel and a custom-implemented class derived from Icon.
doesn't this help? Java gradient label example
And if you understand (or can translate from) portuguese, there's also this discussion with a solution at the end