How to cross-fadeing image in Android - android

Basically, I have images that I'd like to to update them sequentially into the same view to create custom ProgressBar.
I found Tumblr to do just that with their ProgressBar(ImageView?).
Here I put the animation side-by-side to show how the image actually cross-fade from Aa into a camera.
Exactly what I wanted:
Cross-fading effect
Indeterminate
Use the same view (I dumped view hierarchy to check)
Animation during transition (The image actually pop a little when spinning and cross-fading into the next image)
So far I have tried:
1. Frame Animation,
this allows for unlimited item(s) with definable durtion. However, it
doesn't cross-fade the image and there's no way to listen to the
transition's event to apply other animation, etc.
2. Transition Drawable, this allows cross-fading between EXACTLY two drawables. So this doesn't allow for the number of items and interminate duration as well.
I also came across CrossFadeDrawable by Romain Guy just now but it looks like it's only coded to support only two Drawable.
Right now I am not very sure if I'm approaching in the right direction or is there something I need to learn in order to do this kid of effect?

I'm not sure if you are approaching this direction but isn't this what you are looking for:
http://www.youtube.com/watch?v=atH3o2uh_94

Related

Android varied image position alignment in single layout

I am creating a game with circular buttons. I am thinking about a strategy that allows me to display variety of buttons in variety of positions in the same screen in an efficient way.
Like,
Sample images:
Image 1: 1 button
Image 4: 4 Buttons
The game works on seconds and I want the images to be changing so smoothly and should not take much time for transition. My ideas to implement this are below. Please advise me the best way to achieve this.
Use Grid view and populate items as required.
Use Open GL to display buttons.
Use a fragment and assign layouts as required.
Any other perfect way you suggest.
Note: I don't use strips to animate. All I want to do is just to do some calculation according to which button the player picks to click. And my concerns are,
1. Quick and smooth transition of layouts.
please guide me to pick the right path.
Thanks,
Karthick.

How would I go about this?(Android Whack-A-Mole Project)

I'm making a simple whack-a-mole game as my first mini-project for android. I'm not sure how to go about this. I know the basics of setting everything up and such but I'm not sure how to animate the moles and make it so that when the mole is in the up position it can be tapped and a point will be counted. I know I can do an image button and have a counter go up(counter++) but I need to be able to switch frames from the mole in the hole to the mole in the up position. Anyone have an idea as to how to do this? Thanks!
Android allows you to animate objects in a variety of ways. If you only need 2 images to switch, like a button with 'pushed' / 'not pushed' states, you can use a special type of Drawable called a selector (which allows you to specify different drawables for the various states of the target).
If you need more than two images, you may want to use the simple View animation that Android allows you to create using xml. For instance, you can create an xml animation that specifies an image to move/rotate/scale from one initial position to another, creating the in-between frames for you.
Android also has a newer, more complex and full-featured form of animation (which you probably don't need to go into).
Both of these animation systems are detailed at :
http://developer.android.com/guide/topics/graphics/animation.html
Otherwise you will need to create a series of images that you iterate through at a steady pace (which is the fundamental idea behind animation).
I've already made this before, I'll give you an overview, just check my post here: Simple Whack a Mole overview

Create a view carousel

I'd like to create something like a carousel with views. A continuum queue with an indetermined amount of the same type of view (just like a list), but when swiping left/right, (or up/down) it would move to the next/previous view (I could be cool if it did that with an animation, too). Plus, I also need to move though it by buttons. For example, "move to view 20".
Could you give me an advice on what to use for my purpose? Thanks in advance
Edit: By the way, grey big thing in the picture represents the current view, while the other thinner rectangles are the preceding and following view.
Please take a look on this answer Android page control like book?
You can make gaps between pages with setting margins or padding.

How to turn the page [duplicate]

Is there a simple way to do the Curl page flipping animation? A Curl animation is animation of pages flipping, including the page above rolling and the shadows over the lower page.
What is the recommended way to do a "gallery" that displays two pages at a time (just like a book)?
Is it:
Letting the adapter display a linear layout of two images at a time? (it won't let me show a page flipping over the other like a book)
Using two pages, placing somehow one near the other, and then when it's time to animate -move the next two pages over?
What is the better way that would enable displaying the left page flipping over the right page?
I'm implementing a 2D page curl in the native canvas. Check my answer in: Implement page curl on android?
EDIT: The code project of my implementation: http://code.google.com/p/android-page-curl/
EDIT2: Links updated
I am using this code. Its really really perfect for any one to understand and use. Thanks a lot to Harism
GitHub Link for Page Curl Animation in android With OpenGL
I haven't worked on the android before, but it seems to me the best way to do a page flipping type of display would be to draw it in three layers. The first being the first page's text, the second being the "page" underneath, and the third being the next page. If you draw them from back to front, the only thing the user will see will be the text on the first page.
Now, Once you have that, you'll want to do some sort of curling/flipping animation based on whatever controls you are using. Simply choose whatever method works best for you for doing that animation, but while you are doing that, have the part of the page that isn't there anymore alpha'd out. This will allow you to see the text of the page underneath (Okay, I lied. You'll need a background behind that text too).
The problem at this point is you're still drawing the text twice over the same space, so you'll want to blend the first page's text with the animation under it. In this way, the text that is over the 0 alpha sections will be invisible. It won't bend with the animation, so that may still be an issue, but depending on the speed of the flip that might be fine still. When the animation is done, simply set the first page = the second, the animation reset to plain white, and the second page = the new second page.
The shadow effect can be done simply by partially alphaing out some black behind the page turn animation. Draw over second page (as the animation layer already is doing) and voila!
I believe your two page question could use a very similar method. Good luck
This is 3d animation project (based on OpenGL 2.0) - http://anettosoftware.co.uk/npc.php

Android page Curl animation

Is there a simple way to do the Curl page flipping animation? A Curl animation is animation of pages flipping, including the page above rolling and the shadows over the lower page.
What is the recommended way to do a "gallery" that displays two pages at a time (just like a book)?
Is it:
Letting the adapter display a linear layout of two images at a time? (it won't let me show a page flipping over the other like a book)
Using two pages, placing somehow one near the other, and then when it's time to animate -move the next two pages over?
What is the better way that would enable displaying the left page flipping over the right page?
I'm implementing a 2D page curl in the native canvas. Check my answer in: Implement page curl on android?
EDIT: The code project of my implementation: http://code.google.com/p/android-page-curl/
EDIT2: Links updated
I am using this code. Its really really perfect for any one to understand and use. Thanks a lot to Harism
GitHub Link for Page Curl Animation in android With OpenGL
I haven't worked on the android before, but it seems to me the best way to do a page flipping type of display would be to draw it in three layers. The first being the first page's text, the second being the "page" underneath, and the third being the next page. If you draw them from back to front, the only thing the user will see will be the text on the first page.
Now, Once you have that, you'll want to do some sort of curling/flipping animation based on whatever controls you are using. Simply choose whatever method works best for you for doing that animation, but while you are doing that, have the part of the page that isn't there anymore alpha'd out. This will allow you to see the text of the page underneath (Okay, I lied. You'll need a background behind that text too).
The problem at this point is you're still drawing the text twice over the same space, so you'll want to blend the first page's text with the animation under it. In this way, the text that is over the 0 alpha sections will be invisible. It won't bend with the animation, so that may still be an issue, but depending on the speed of the flip that might be fine still. When the animation is done, simply set the first page = the second, the animation reset to plain white, and the second page = the new second page.
The shadow effect can be done simply by partially alphaing out some black behind the page turn animation. Draw over second page (as the animation layer already is doing) and voila!
I believe your two page question could use a very similar method. Good luck
This is 3d animation project (based on OpenGL 2.0) - http://anettosoftware.co.uk/npc.php

Categories

Resources