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.
Related
I need help in make the background of my app as gallery of photos... is that possible? and how to do that?
You can use a GridView to show images in column and row fashion. For more information you can take a look at this article for implementing gridview.
You can do this by assigning an id to your parent layout and then in java you can change the background image after a certain action is performed.
You can use Asyymmetric Gridview to achive attractive view of gallery
you can use this library
Yes You can I did it before by creating an animation that contain the images then I set this animation as backgroud
// Type casting the Image View
ImageView view = (ImageView) findViewById(R.id.imageView1);
// Setting animation_list.xml as the background of the image view
view.setBackgroundResource(R.anim.animation);
// Type casting the Animation drawable
AnimationDrawable frameAnimation = (AnimationDrawable) view.getBackground();
frameAnimation.start();
example animation 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="3000" />
<item android:drawable="#drawable/image_2" android:duration="3000" />
<item android:drawable="#drawable/image_3" android:duration="3000" />
</animation-list>
I have a animation list contains the following items
<?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/b1"
android:duration="500"/>
<item
android:drawable="#drawable/delay"
android:duration="1000"/>
<item
android:drawable="#drawable/b1"
android:duration="500"/>
<item
android:drawable="#drawable/delay"
android:duration="1000"/>
<item
android:drawable="#drawable/b2"
android:duration="500"/>
Now, when the animation is running or has started by the following
code,
img1 = (ImageView)findViewById(R.id.stimulichangeid);
img1.setBackgroundResource(R.drawable.erp_simple_presentationlist1);
AnimationDrawable splashanimation = (AnimationDrawable)img1.getBackground();
splashanimation.start();
I want to click some button when in animation list "b2" drawable
appears on the imageview.But in a running animation, how to access a
particular item(in my case b2). When b2 comes i want to press a button
and do something. i was thinking to assign id's to every item. if yes,
then how to access that particular item with its id when the
animation is running. please suggest some way to solve this problem.
thanks in advance
AnimationDrawable isn't kind of layout so you can't catch any child view with order. It just replaces a drawable with a new one, so you need a kind of listener returns the order of new drawable. And native implementation doesn't have these kind of listener.
There is some custom AnimationDrawables and you can modify one of these for your need.
I am trying to get familiar with the new design guidelines of Android Lollipop. So especially for animations, I try to achieve something like these detailed animations for icons or buttons: http://www.google.com/design/spec/animation/delightful-details.html
I was wondering how they did that?
In my special case, I have a floating action button, which is used to drop an item in a shopping cart. After the user presses the button, I want to animate the icon drawable inside that button. The animation shall have a sliding effect where the cart is moved out to the bottom of the button and the check mark is moved in from the top of the button.
I found a ViewFlipper (http://www.inter-fuser.com/2009/07/android-transistions-slide-in-and-slide.html), however I want to keep the button in place and only animate the icon inside the button.
On the other hand I found AnimationDrawables (http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html) but there, I have to create each frame by hand, which is also odd.
What's the best way to achieve that?
I wonder if fab support that now, however, you can always create your own.
Create a custom linear layout that contains image view. Make it round like fab. You can then look at this animation examples
Hope it helps. Happy codings.
You could use a frame animation:
you create 15-20 frames for the animation you want to make.
You create an animation list drawable, for example animation_list.xml:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:duration="50"
android:drawable="#drawable/frame_01"/>
<item
android:duration="50"
android:drawable="#drawable/frame_02"/>
<item
android:duration="50"
android:drawable="#drawable/frame_03"/>
<item
android:duration="50"
android:drawable="#drawable/frame_04"/>
<item
android:duration="50"
android:drawable="#drawable/frame_05"/>
<item
android:duration="50"
android:drawable="#drawable/frame_06"/></animation-list>
Then you put this drawable as a src inside your custom FAB.
Now you can start the frame by frame animation (when the FAB animation finishes):
ImageView mImageViewFilling = (ImageView) findViewById(R.id.animated_imageview);
((AnimationDrawable) mImageViewFilling.getBackground()).start();
I see that i can set 2 images in one ImageView in android using a new Drawable XML file under resources, called for this example my2img.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/img1" />
<item android:drawable="#drawable/img2" />
</layer-list>
and Apply to the imageView.
testimage.setImageDrawable(getResources().getDrawable(R.layout.my2img));
But how can i access one of the 2 images from Java code ?
For example on runtime i want to show the first image full overlapped by a only a slice of the other image, another moment the full second image..and so on... just like a progress bar behaviour.
Is there any code sample ?
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