Android animation picture change - java

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.

Related

How do I make it possible to scroll over an Image in Codename One?

I have a Codename One App that has Images in it.
However, whenever I'm trying to scroll when the cursor is on the image it doesn't work.
Edit:
1: (Some Component) Scrolling works;
2: (Image) Scrolling doesn't work
Link is HERE
Image img = Image.createImage(FileSystemStorage.getInstance().openInputStream(i.getImagePath()));
imgViewer.setImage(img);
imgViewer.setHeight(img.getHeight());
imgViewer.setFocusable(false);
This is the code that creates the ImageView.
The Image View is inside a Container which has the Layout BoxLayoutY (vertically scrollable)
That Container is in the Form which is the most bottom Layer, also set to BoxLayoutY
I suppose there must be some function that I can call to make it possible to scroll when the cursor is on an image, but I have no idea, which one that is.
Don't use ImageViewer use Label or ScaleImageLabel. ImageViewer grabs your pointer events to pan the image and allows zooming into it. It's designed for use over the entire Form and won't work well in a scrolling scenario.
If you want that functionality I suggest putting a small thumbnail in a Button then when it's clicked show the ImageViewer in a separate Form at the center of a BorderLayout.

Javafx ImageView real image position

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.

Jlabel Extra Clickable Space

I create buttons using jlabels, so I can make a image into sort of a button. The only problem is, is that jlabels are square, therfore if i click somewhere within the square where the picture is not contained, it still runs the jlabel.MouseClickEvent. Is there any fix for this, or another component that i could use?
Ex. If i click this on the corner where the circle is not showing, but the square is still there, then the event fires.
Any fixes/different components to use? Thanks!
If you are just using simple Shapes for the images then you might be able to use the Shape Component found in Playing With Shapes.
The ShapeComponent will only respond to mouse events within the bounds of the Shape.
Otherwise the solution is to override the contains(...) method of your JLabel to check if the mouse point is in the bounds of your image, or in your case if the pixel at that location is not transparent.

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

Categories

Resources