Image that has multi clickable zones/surface/area - java

I want to have an image on the android screen where different parts of the image can be clickable. What I mean is that, If its an image of 3 circles, I want to be able to click each of these circles,
Then I can add different functionalities to each of these clickable circles.
For an instance in this image below I want to be able to click each distinct color. Is it possible to have on-touch-listener and get you the color ? and can it be an image or has to be drawn in Java OR XML ?

I found a really good widget that helps you make any image muli-clickable. They have some good notes on how to use their widget as well.
The widget has a similar approach as Image mapping in html. The good thing about this widget is that the image can be zoomed and it will not lose the coordinates or areas associated to specific clicks.
Here is the link to their website. the guy who made the widget apparently had similar problem and came up with this widget.

Another solution would have been
creating an ImageView containing the png file referenced
making the whole ImageView clickable
setting an OnTouchListener to the ImageView which overrides the onTouch method
check the colors of the image pixel at the touch position
This is often done with an invisible mask image with one color for each zone (see the popular detailed tutorial), but here the image itself has distinct colors for each zone which makes it more interesting.

Related

Make an imageview blurred towards the vertical edges in Android

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

android imageview come from over screen

hi.
I have a problem with android layout.
gif is what designer want I make. and I made things successfully but menu.
png(alpha image) is our menu image. last 40px of height is want to display.
and if user touch that 40px of image is coming down just like gif image shows.
I don't have any idea how can make that. Constraint Layout doesn't support negative value.
ps. png is based on 1080 height resolution. but I will add dynamic resolution calcaulator function, so don't mind about 40px. 40 just mean 'want to display part of imageview'
SOLVED.
make imageview in constraint layout xml and inflate it.
then you can set x,y location programmatically.
I confused it. because when I tried it, It doesn't work. you must know view has relative location.

How can you crop an image to pieces in javafx in order to create a game puzzle with tiles?

I am trying to do a project with javafx but I can't create the figures to a puzzle game with tiles, in order to push them with the click of a button. How can an Image be cropped and saved as an individual tile ?
The ImageView class is used to display an image. It has a viewport property that represents the portion of the image it is viewing. So you can create multiple image views from the same image, each with a different viewport: then you can add the image views to a pane of some kind, register mouse handlers on them, etc.
If you actually need to store each piece as an individual image, you can snapshot the image view to create a new Image from it. You'll probably find you don't need this, however.
You might want to try PixelReader and WritableImage APIs from JavaFX platform.

Android - Setting colour to image

I'm getting stuck at a certain part of my app.
In my app, I have a few icons. The icons are completely white with transparent backgrounds. Is it possible for the user to set the colour of the icons without messing up the transparency? I tried searching a lot, but couldn't come up with anything. Could someone help me out?
Also would it be possible for the user to set custom icons from any folder as per their choice?
Thanks.
Yes it's possible. You have to create bitmap from resource How to set a bitmap from resource, then search bitmap for white pixels and change them to desired color (pix - by pix), then just set result bitmap as button or other layout element bitmap.

Android border layout with an EditText overlapping on it

I want to code a layout like the following image in xml in Android.
One approach would be to have a RelativeLayout and make a 9 patch rounded rectangle border image, have it as the background around a layout which has the two blue buttons, and then have and EditText overlapping it, with its background set to a red color.
What could be other approaches?
As I understood your question you want to make series of photos ..like Gallery application
you can do it with more option also.
1)this is gallery type application .
so . you can use this basic code :Android Gallery Application
2)If you want to see all the photos in circle this is also possible..
It depends upon your need ..please write in brief you want more...

Categories

Resources