I'd like to display a animation with transparent background, on a transparent activity. How can I realize it with Android? I thought about flash, but the user has to have flash installed, right? I'd prefer vector graphics instead of gifs.
Thanks a lot in advance!
Example:
The best way to show an animation is to store them as PNGs and do something like this for an animation, put this in your drawable folder.:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="#drawable/ant1" android:duration="100" />
<item android:drawable="#drawable/ant2" android:duration="100" />
<item android:drawable="#drawable/ant3" android:duration="100" />
<item android:drawable="#drawable/ant2" android:duration="100" />
</animation-list>
If you want to use vector graphics, then you have to manually switch the images. You could look into svg-android, which is a great way to use simple vector images in Android.
Hey you this library for animation of background image and set theme Theme.Transparent for activity...so you can achieve your requirement This is the link might be usefull...KenBurnsView
Related
I am new to Android. I Have Listview in My Activity and it's working Fine. But suddenly in mind one thought is going on. Is there any way to put gif animation in background of my Listview and display data to on gif Image. Let's say that In Our Listview we Have set background color as follow.
android:background="#color/Mycolor
so it can change the whole Listview color But I want to
display gif Animation Like small Image of Birds are flying in
Background
. If it is possible then give suggestion.
Any Help will be Appreciated.
I think this is the way you can set,first you need to divide gif animation in indvidual frame,then you need to create one xml for background and use animation-list and add all the frames of gif image and set that xml as background
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="#drawable/frame1"
android:duration="1000"/>
<item
android:drawable="#drawable/frame2"
android:duration="1000"/>
<item
android:drawable="#drawable/frame3"
android:duration="1000"/>
....
</animation-list>
use an Imageview in row background and play gif on it using this component.
I found below link for use of Gif at ImageView But I don't know how use it.
I want show Gif Image at ImageView from sdcard or assets folder.
help me . Thank
http://www.java2s.com/Open-Source/Android_Free_Code/ImageView/Download_Free_code_ImageViewEx.htm
also I use Tutorial: How to play animated GIFs in Android.but when I use that.it show's only one gif at Activity.I want show many gif picture at one Activity and at different locations of screen.
if you wanna show gif animation, Try this because android and ios can't support this kind of animation
Create in drawable folder my_gif.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="#drawable/image_1" android:duration="100" />
<item android:drawable="#drawable/image_2" android:duration="100" />
<item android:drawable="#drawable/image_3" android:duration="100" />
</animation-list>
add parameter for your img view
android:src="#drawable/my_gif"
What is the best way to design and embed an animation into an android app.
(I'm not talking about transitions and activities in/out animations.)
I can think of 2 ways of doing it:
designing the animation with flash or something similar, export png-sequence with transparent bgs and creating an animation from the images in an xml file (How do I write this kind of xml?)
creating a grid of images with all the frames of the animation that I've created
and save it into one image. than using something like background-position in css in order to move the visible area of the image on each frame enter (By Java code, or by xml)
which of this is better/most common? and how do I implement the solution (if there is a better solution - that would be great).
and what programs do you usually use for this kind of task
(the goal is to achieve something that works like the frog in cut the rope or the birds in angry birds for example)
thanks!
I used simple animation in one project... It's on your first point... A sequence of *.png files in /res/drawable, and *.xml like:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="#drawable/s250" android:duration="200" />
<item android:drawable="#drawable/s251" android:duration="200" />
<item android:drawable="#drawable/s252" android:duration="200" />
<item android:drawable="#drawable/s253" android:duration="200" />
<item android:drawable="#drawable/s254" android:duration="200" />
<item android:drawable="#drawable/s255" android:duration="200" />
<item android:drawable="#drawable/s256" android:duration="200" />
<item android:drawable="#drawable/s257" android:duration="200" />
<item android:drawable="#drawable/s258" android:duration="200" />
</animation-list>
... and source...
final ImageView pygalo = (ImageView) findViewById(R.id.imageanimation);
pygalo.setBackgroundResource(R.anim.animation);
final AnimationDrawable pygaloanimation = (AnimationDrawable) pygalo.getBackground();
pygalo.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View vp) {
pygaloanimation.stop();
pygaloanimation.start();
}
});
It is very easy to do...
Can anyone suggest me how can I use a refresh icon in my activity? I mean to say that my activity takes time to retrieve data from the server during that time I want to show the refreshed logo moving indicating the user that data retrieval is still in progress. So can anyone suggest to me how that can be done? If possible with an example.
I'm not sure, but what about creating your animation with the "refresh logo" you need?
<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="200" android:drawable="#drawable/stat_sys_wifi_signal_1_anim0" />
<item android:duration="200" android:drawable="#drawable/stat_sys_wifi_signal_1_anim1" />
<item android:duration="200" android:drawable="#drawable/stat_sys_wifi_signal_1_anim2" />
<item android:duration="200" android:drawable="#drawable/stat_sys_wifi_signal_1_anim3" />
<item android:duration="200" android:drawable="#drawable/stat_sys_wifi_signal_1_anim4" />
<item android:duration="200" android:drawable="#drawable/stat_sys_wifi_signal_1_anim5" />
</animation-list>
Playing with duration, you can display whatever you want at the time you want. More info here.
After, define and show your own CustomDialog, like this example, instead of the standard progess dialog.
If your "refresh logo" is a static image, previus link should be enough.
Use AsyncTask with ProgressDialog.
For more information, here is a great article given: https://sites.google.com/site/androidhowto/how-to-1/asynctasks-with-progressdialogs
You could use a ProgressDialog. There's also the ProgressBar widget.
create custom view , which contains a rotating portion of circle visible .
I want an animated gif, since this isn't possible in Android I am using individual frames in a transition.
except it seems like the transition class only will show two frames ever! I saw other animation methods but they didn't seem to apply to what I was doing, or seemed old and convulated like for an older infant android build
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/activateanima"></item>
<item android:drawable="#drawable/activateanimb"></item>
<item android:drawable="#drawable/activateanimc"></item>
<item android:drawable="#drawable/activateanimc"></item>
<item android:drawable="#drawable/activateanimd"></item>
<item android:drawable="#drawable/activateanime"></item>
<item android:drawable="#drawable/activateanimf"></item>
<item android:drawable="#drawable/activateanimg"></item>
</transition>
How do I animate an image to behave like an animated gif, in place. no rotations or translations here. Using android 2.1+
Are you after a Frame animation? See: here. This will play a standing still animation.
Example from above site:
XML file saved at res/anim/rocket.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="#drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="#drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="#drawable/rocket_thrust3" android:duration="200" />
</animation-list>
To use:
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start();
Just use a view flipper to flip between the images. Just define your in and out animations to be 0seconds long and they should be instantianous. (but use alpha to be sure). View flipper has the benefit of also auto animating and auto starting