Javafx ImageView real image position - java

I'm trying to realize a mouse over effect on a button.
What I have is a button with an ImageView in it. The ImageView displays a image in shape of a triangle. So there are areas inside the ImageView in which no picture is displayed.
Can someone explain me how it's possible to only start the mouse over event when the mouse move over the actual image (not the blank areas).
Many thanks in advance.

Related

Unable to fill button With a bitmap image created from a canvas drawn with path

I have a button and a bitmap which I drew using path in MainActivity.java.
I applied the bitmap to my button as a background drawable. So the image is already on the button.
The result I obtained is as shown in the image below.
The black boundary is the button boundary while the image is the gray arrow. Is there a way to reduce the button boundary such that it fits the arrow exactly?
I have already tried to set the button to the width and height of the image and also clipped my canvas using canvas.clipPath(path); in hope that the size of the canvas would be around the size of my path
**Note that I did this using button and not image button as I will be adding text on top of the button on the bitmap image
Put android:backgroud="#drawable/yourimage" in your button's properties.

User Interface buttons on an image view

cell image
Im using this picture above for my app I am making on android studio. As you can see, the image has different cells; I want to the user of the app to be able to tap each cell and the colour will change.
I have tried putting buttons on top of each cell but the buttons do not overlap directly on top of the selected cell.
Please if anyone has suggestions on how I can create a user interface with each cell of the image, let me know.
Thanks

how to restrict the mouse just on the icon on java

I have button on frame. On that button I put an image, which as you see that is a search icon. I remove the visible border on the button. But still I have two questions:
when I put the mouse on the button, the image and also the invisible button border is clickable, what I need is restrict it just on the icon.
I want to make the icon focusable by clicking like click on the simple button.
Search Icon:
What sort of image file format are you using? If it's a format with transparency support, you'll have to implement an algorithm that checks whether the click coordinate is inside of the non-transparent pixels of the icon you're using. You'll have to offset the rgb checks on the image pixels by the position of the image on your frame as well. Use this as a reference - Java Image Processing

How to use NinePatch image in Scene2d but not as button?

I'm having no problems using NinePatch images as buttons, but my problem is this:
I have one rectangle (An ImageButton using a NinePatch image) that when clicked on calls "clickedOn()".
Over-top of this rectangle I draw another ImageButton (using a NinePatch image) that doesn't have a listener attached, but it still cancels out the listener underneath.
Is there a better way to add a NinePatch image to the stage so that it is just a plain old image and doesn't block listeners? Or are NinePatch's added to a regular SpriteBatch rather than a Stage? (I was hoping I could just use a Stage as my renderer)
I tried stage.addActor(NinePatchDrawable) but that doesn't work.
Thanks
To let the click pass through I have found you can set the image to not be touchable
tempimagebutton.setTouchable(Touchable.disabled);
If anyone is aware of a better class to use than ImageButton to simply display a NinePatch on a stage though I'd appreciate the help

Android animation picture change

I want my program to do the following:
In frame there is a button and some image. When button is clicked I want this image move to the left until it will not be visible on frame (be outside of frame) and at the same time next image should come from outside of the frame to the center of it and stops there until the button is clicked again.
Should I inflate some ImageView everytime the button is clicked and change their x coord. though property animation? Or I can make two ImageView on frame and one of them would be transparent while other will be visible? And then change their positions and transparency level ("alpha") when button is clicked?
Which is the right way to do it?
A ViewFlipper might do what you want. From the javadoc:
Simple ViewAnimator that will animate between two or more views that have been
added to it. Only one child is shown at a time. If requested, can automatically
flip between each child at a regular interval.
Presumably, you can add two ImageView instances as children of the ViewFlipper and then animate between them with a slide animation. There are some answers on SO detailing this. Try searching for ViewFlipper.

Categories

Resources