View's Properties not changing with Property Animation - java

I'm trying to animate a floating action button to a new location and have it be clickable there, but when I animate it via
listOptionsButton.animate().xBy(-200);
I can't click it in the new location that it goes to.
I thought that using this kind of animation would move the view itself and not just the rendered pixels.
Can someone explain what's happening and help me find a way to move my button and be able to click it at the start and end locations?

I fixed my issue. It turns out that I animated the button outside of the parent layout and even though I used property animation, the button wasn't reachable because it was outside of the bounds of the parent.
I don't know how to elaborate further, because I honestly don't fully understand why this was an issue, but I ended up making a compound view that took up my entire screen so it wasn't an issue in the end.

Related

Draggable overlay that can go offscreen?

I have created an overlay menu that is a rectangle.
It displays on top of everything else while active. All other apps, the home screen, etc.
If you click anywhere outside of this rectangle your click hits
whatever is visible.
If you click the red part it allows you to drag the menu around the
screen. Clicking the green part performs some function.
I have created this rectangle from inflating layout xml. The rectangle itself is a relativeLayout and the green and red parts are both imageView children.
Since I'm unable to move the relativeView off screen and since the background needs to be clickable my only solution was to calculate margins and apply them to the relative view to imitate the desired effect.
However, the code to calculate these margins is almost 50 lines and fairly complex and hard to understand at a glance if someone else needs to refactor. I can post the code but I don't believe it's relevant to the actual problem's context.
Is there a much simpler way to do this that I'm missing? Is my approach wrong?
I hope this simple project may help you Android Floating Widget

JavaFX Keep view in window

I have this problem that I have been trying to solve for about an hour now:
I want my app to resize in this fashion. When the window gets smaller, the views should move to stay inside the layout. So I don't need them to necessarily change size, but I do need them the move to stay within the window.
I have already tried GridPane but I want to be more precise than a grid (like AnchorPane) since I will have many views in the layout. However, if there is a workaround involving GridPane, I will be open to those solutions as well.
Thanks for any help and please leave a comment if you need further clarification.

Draggable border to resize view

The past few months I've been on a mission to implement widget support in my home screen replacement for Android, and it's proving rather difficult. I can now add and remove widgets to/from the home screen, but they can't be resized or moved yet. Currently what I'm trying to achieve is to resize them. To do this I have every widget embedded in a View, over which I put an overlay to make sure the touch events don't get caught by the widget underneath it (which caused trouble in past attempts).
What I have now is this layout for the container; http://www.hastebin.com/uwocaxukel.xml
The widget is put in the FrameLayout with id widgetContainer. As you can see in the screenshot below there is an orange dot in the middle of every border.
Now what I've always tried to do so far is catch touch events, figure out whether the user is trying to drag one of the borders (MotionEvent.ACTION_MOVE), and if he is, change the required properties in the LayoutParams object and call this.requestLayout () on the view. This is finicky, and less than ideal. Very often the touch events would stop registering because the user dragged faster than the view could refresh = user is no longer on the view which is listening for touch events, or the border would be too thin to hit.
So far it's all been very finicky. But there are other apps which seem to do this pretty much perfectly. Is there a library, a class I've overlooked, or something else I can use to achieve my goal?
This is an example of something that kind of worked, but was very finicky and just not remotely user-friendly; https://github.com/RobinJ1995/be.robinj.ubuntu/blob/869d48af2e7a3d8f0332f84edd2a8cd28564424a/UbuntuLauncher/app/src/main/java/be/robinj/ubuntu/widgets/WidgetHostView.java#L75

Eclipse android widget moving

I am designing my activity screen using eclipse but whenever I move an object e.g. a button it snaps around and I find it hard to position things where i want them.
Is there some setting I can change as as soon as I add a second button it snaps the other button to another position it is so annoying!
Also if I have an image button why can't i resize this, even with a normal button if i try to make it larger it just fits to the text and wont make the button bigger or it just flicks to a random place on the activity?
thanks
Probably you're trying to place components freely in the View but you're not considering the LayoutManager behavior. If you try to position your component in a LinearLayout, for example, the components will be placed following its rules, and these components will not stay where you drop them.
Try to understand better how the layouts works on Android. But for now, the AbsoluteLayout or RelativeLayout may be what you're looking for.
About the components size, you'll need to understand better how to use layout properties for these components. See the question How to size buttons for more information.

How to change an image depending upon ScrollView Direction (Android)

Basically I want to change an image depending upon whether the user is scrolling up or down in a Scrollview.
I know how to change an image dynamically but I can't figure out how to return the direction the Scrollview is currently moving.
Thanks
This answer will help you on implementing a scroll change listener. Using the value it provides, you can determine whether it is up or down.

Categories