Draggable overlay that can go offscreen? - java

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

Related

Dynamically change width of a view with animation

I have a case where have to dynamically change width of a button placed alongside another button in a horizontal linear layout. Button width change depend upon certain condition.
I have already tried many of solutions posted at stackoverflow, but the animation is never smooth. Lags on low-end devices. Some time the text within button seems to be sliding in which I don't want.
Here is what I want to achieve, pls see here how smoothly button width changes in google messages just want to achieve same animation.
Just for reference i've already top voted solutions here, for example Resizing layouts programmatically (as animation)

Guidance for the background, Please design

I need to place two boxes next to the recycle view. One blue box with text "working" and one red box with text "not working". It is to tell the user which way to swipe the item either left or right. Is this possible, I am struggling even to rotate the text and display it like I want.
I have tried designing a custom xml, but no luck. its just for gradient stuff. which I don't want.
Please see the attached images of what I want.

How to create a floating view over another view in android

I don't know exaclty how it is called, but I got a screenshot:
Basically, in this case, I press a button and this window from "FC Barcelona" pops up, occupying about 3/4 of the screen. After it is opened I can drag it up and down. If I drag it up, it occupies the whole screen, if I drag it down, it disappear.
How can I use this tool or how it is called in android?
What you want is a BottomSheet. You can find an example on how to do it there at the Design Support Library: Bottom Sheets section.
http://android-developers.blogspot.de/2016/02/android-support-library-232.html

What are these element called?

I'm developing my first real app and found inspiration in Instagrams design.
I would like to know what the red and blue area is called and if these exist within androids own libraries so I can implement them.
I guessing that the blue area is something called carousel list/tab-list or button menu or maybe a lot of radio buttons? If you, for example, press on the Juno filter, the list will automatically scroll towards left, so you can see the rest.
The red rectangle is horizontalscrollview and the blue rectangle is LinearLayout with three child.
there are multiple options but I think the blue box in LinearLayout and Red one might be a simple scrollview

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

Categories