When using motion layout, I built a simple motion scene which changes a cricle from width/height of 100dp to 1000dp with a duration of 2000ms.
Now I want to know programmatically when the animation is finsihed (Observer/Listener?)
I didn't found any built-in features or blog posts which are solving this problem.
Any ideas?
here some tricky way using transition listener
or use Link
and modify on it as you need
Related
I am currently prototyping making a screen with bubbles (circular xml drawables for now) that have a start and end position and animate in a floating bubble fashion.
I am currently using the new Motion Layout provided in the Constraint Layout alpha build and right now it is both proving a pain to adjust the values (eagerly awaiting the timeline animation tool) or never looking correct.
Is anyone aware of a library that has similar functionality or is Motion Layout the best bet?
Whenever i look for bubble stuff it is regarding the ripple effect on buttons etc and so it's proving a little tough to find anything.
I would ideally like to be able to add bubbles dynamically with a start and end point and then start animations independently but just getting the animations looking right is the main goal right now.
As aside question - does anyone know the official/expected release date for Constraint Layout 2?
Appreciate any pointers.
I want to make a view that looks like a weight scale, like the image below:
For that I thought of using a horizontal scrolling RecyclerView with view holders representing each value of the scale and that works fine, but I can't figure out how to make it curved or if it's possible. I want it to be curved to look more like a weight scale. Does anyone know how I can manage to do that?
I'd say don't go with RecyclerView. It's not intended to be used for such purpose and it might be very time consuming to make it work. I think that the best way is to write a view from scratch. You can draw the scale manually using onDraw(Canvas), simple math and a bunch of drawing operations. The most difficult part would be to add a scroller to get the fling gesture working nicely.
I'm developing an android app that User select an emoticon.
I'd like a nice swipe gesture selection with horizontal scroll.
can i create a horizontal scroll to select emotion.
this is an example
https://www.dropbox.com/s/n298h17r3fs2wvj/scrollswipe.jpg
Have you tried using GestureDetector.OnGestureListener?
http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html
I think onScroll() is just vertical, but I might be wrong; onFling() is definitely horizontal but requires a bit of velocity.
If you haven't looked at GestureDetector, then you should write a simple demo for yourself with it in any case.
On the jpeg it looks like you are after a very specific hook like curve. If that's the case, then you need to implement detection yourself using the lower level, more flexible View.OnTouchListener.
http://developer.android.com/reference/android/view/View.OnTouchListener.html
Is it possible to rotate views in XML with APIs previous to Honeycomb - maybe with the support package? Or is the only way to create a custom class, like described here Vertical (rotated) label in Android
Edit: What I need is a statically rotated view (specifically a TextView, but I guess it's enough to know how to do it with a View). Starting with honeycomb there's a rotation attribute which can be used in XML. I need something like that.
The only thing I have found until now is use an animation with duration 0 but this still moves a bit at start and I don't want that. I tried setting the views invisible and attaching a listener to the animation which makes them visible on animation finished callback, but that made strange results... that changed the position of the views, for some reason.
The best way is with the custom subclass implementation that you linked to, where you can rotate the canvas and resize the view appropriately. This ensures that the view bounds are also set to match the text that is drawn.
The only method of transforming views externally prior to HC is the animation framework, and applying an Animation to the view with a duration of 0 and fillAfter set to true will work, but you may notice flickering on some devices as often the view will render normally on its first frame and then animated to its final position from that point onward. You can work around this by hiding the view and displaying it a bit late...but you can see how hacks are starting to stack up.
In addition, doing an Animation prior to HC will not transform the view bounds themselves, so you won't be able to neatly pack other views around this one because its position from a layout perspective will still be the rectangle calculated for the horizontal (non-rotated) text.
The simple subclass is definitely the preferred method.
HTH
Is it possible to rotate views in XML with APIs previous to Honeycomb
There is RotateAnimation. However, depending on what you are trying to accomplish, that may not meet your needs.
I am working on a project that involves painting on images.
To delete the unwanted lines or curves i have to draw a border and X button to delete it.
I have a relative layout where i have the freehand drawing canvas. on edit mode i should make them as u see in the pic, where i have to create button on a varying x,y positions.
i am confused how to achieve this.
Thanks in advance.
Jana.
I suggest doing this manually rather than using the Button widget. Override the onTouchEvent on the view holding your painting and use MotionEvent.getX and MotionEvent.getY in combination with MotionEvent.getAction to determine behaviour when the user touches the 'button'. Skipping widget creation will improve performance and open up doors to other types of functionality.
You could use the deprecated AbsoluteLayout container for this or keep the RelativeLayout and use layoutMargins to set the location of the buttons. The former is the route you should take despite the container being deprecated as the later breaks the layout paradigm by misusing margins...
You should keep in mind that there are a variety of devices with different screen sizes and setting explicit, pixel based locations is going to be awkward.