Android concertina/accordian/folding animation - android

I'm trying to create an interactive accordian/concertina/folding animation so that a view folds/unfolds on itself when interacted with - in the same way flipboard folds the view, but both sides fold
The way I thought I could do it was to override the onDraw method, somehow duplicate the canvas or the information on the canvas, then draw the first half of the canvas rotated one way, then draw the other half of the canvas rotated the other way so that they meet in the middle, however I can't seem to grab the information from the canvas! Is it possible to grab a bitmap/snapshot from a canvas?
The only other way I think it's possible to achieve this kind of animation is with OpenGL.
Any help are greatly appreciated.
EDIT heres a good example of what i want to achieve http://www.nytimes.com/interactive/2008/03/28/arts/20080330_FOLD_IN_FEATURE.html

check this archive to acheive fold animation
code: http://developer.android.com/shareables/devbytes/FoldingLayout.zip
modifies it to make it work for lower version up till API level11

Related

How to draw complex UI scroll?

Hi everyone.
I want to do implement such UI element as you can see at this video:
So I'm stuck with this scrolling dashed arc. It looks like RecycleView, but I wonder how to calculate such geometry. I've tried to do something with Canvas and onDraw method overriding, but how to update "rotation" of this scroll?(I mean "rotation", because if I change rotation of view, the arc is just rotates itself, not parts of it.
I think I could be implemented with GL 3d scene, but I don't know how...
Maybe anyone know how to do something like this or where I can find information?
Thanks in advance!

Animate drawn image

I've got some problem. I have an image drawn using canvas, and I would like to animate it. I would like to do something like TranslateAnimation, but TranslateAnimation works only with views, and my image is not a view. What can I do?
Personally I haven't worked with Android canvas, but I am fairly certain that what you need to do is this:
Draw your shape on the canvas
Wait for a couple of miliseconds
Clear the canvas
Redraw shape to next immediate position
and repeat this until the final position is reached.
From my little knowledge the canvas is more similar to a piece of paper than to a flash animation. You need to draw, clear, recalculate, redraw. I highly recommend reading some more on the topic. Firstly, I would start with the android canvas reference: http://developer.android.com/reference/android/graphics/Canvas.html
and then try some tutorials like canvas frame by frame tutorial for android : http://developingthedream.blogspot.ro/2011/01/android-canvas-frame-by-frame-animation.html
And also I highly recommend looking up things on google first before posting a question on stack. There is a good chance, especially if you are a beginner, to find existing tutorials with everything you need and more. Good luck learning.

android canvas scroll in the simplest form

i am new to android and cannot find any suitable way to make a canvas scrollable. I have searched a lot but no one's giving a complete overview of what is to be done actually. Just vague ideas & incomplete code examples. Any help would be appreciated. I have extended the from scrollview and have drawn a png image on canvas which is greater than the screen size. Scrollbar do show up but then fade away & no scrolling. what am i missing?
If you mean you have a custom view with a Canvas you're drawing to, then you have to implement scrolling yourself. But fear not! There is a nice things called GestureDetector and Scroller already made for you to make it easy.
You just need to listen to its scrolling/fling events and update xOffset value with which you gonna draw on your Canvas.
Basically in your draw(Canvas) method you don't just call
drawSomething(x, y)
but
drawSomething(x - offset, y)
If I'm describing the problem you have and it's still unclear - let me know, I can expand further.

Draw a Circle With Reverse Filling in Android

Not sure how to do this, or what the right terms are for describing this, but here goes:
I want to make a closing circle animation in my android app, much like the end of this video. I'm guessing what I need to do is somehow draw a black circle but instead of filling the inside of the circle fill the outside. How exactly would I do that, given the tools I have with Android's Canvas class?
Have you tried using clipPath to achieve this?
I was working on the same kind of thing and achieved it by using clipPath of canvas.

Creating a background image that moves from right to left in a live wallpaper

I have a background image that I would like to simply scroll (while looping) right to left. What is the best way to go about doing this? Will I need to use an external library? Are there certain methods built into android already to accomplish this? Is all this accomplished in the doDraw() method?
Eventually I would like the canvas to also draw a stationary Bitmap ontop of that. I think that will be easy if I just use the canvas.drawBitmap() function.
Easy example including X offset
http://android10.org/index.php/articlesuserinterface/256-live-wallpaper-example
and canvas

Categories

Resources