Wave Layout AnimationExample

This example shows you how to create wave animation in grid layout.

Algorithm:

1.) Create a new project by File-> New -> Android Project name it WaveLayoutAnimationExample.
2.) Create and open res/anim/layout_wave_scale.xml file and write following code:

 

<!--?xml version="1.0" encoding="utf-8"?-->
android:rowDelay="75%"
android:columnDelay="0%"
android:directionPriority="none"
android:animation="@anim/wave_scale" />

 

 

3.) Create and open res/anim/wave_scale.xml file and write following code:

 

<!--?xml version="1.0" encoding="utf-8"?-->
android:interpolator="@android:anim/accelerate_interpolator">
android:duration="100" />
android:fromYScale="0.5" android:toYScale="1.5" android:pivotX="50%"
android:pivotY="50%" android:duration="200" />
android:fromYScale="1.5" android:toYScale="1.0" android:pivotX="50%"
android:pivotY="50%" android:startOffset="200" android:duration="100" />

 

 

4.) Write following into main.xml file:

 

<!--?xml version="1.0" encoding="utf-8"?-->
android:id="@+id/grid" android:layoutAnimation="@anim/layout_wave_scale"

android:layout_width="fill_parent" android:layout_height="fill_parent"
android:verticalSpacing="10dp" android:horizontalSpacing="10dp"
android:numColumns="auto_fit" android:columnWidth="60dp"
android:stretchMode="columnWidth" android:gravity="center" />

 

 

5.) Run for output.

Steps:

1.) Create a project named WaveLayoutAnimationExample and set the information as stated in the image.

Build Target: Android 2.1
Application Name: WaveLayoutAnimationExample
Package Name: com.example. WaveLayoutAnimation
Activity Name: WaveLayoutAnimationActivity
Min SDK Version: 7

2.) Open WaveLayoutAnimationActivity.java file and write following code there:

 

package com.example.WaveLayoutAnimation;

import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class WaveLayoutAnimationActivity extends Activity {
private List mApps;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
setContentView(R.layout.main);
GridView grid = (GridView) findViewById(R.id.grid);
grid.setAdapter(new AppsAdapter());
}
public class AppsAdapter extends BaseAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(WaveLayoutAnimationActivity.this);
ResolveInfo info = mApps.get(position % mApps.size());
i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
i.setLayoutParams(new GridView.LayoutParams(36, 36));
return i;
}
public final int getCount() {
return Math.min(32, mApps.size());
}
public final Object getItem(int position) {
return mApps.get(position % mApps.size());
}
public final long getItemId(int position) {
return position;
}
}
}

 

 

3.) Compile and build the project.
4.) This application will show icon of all the application available into your apps folder or available into category_launcher.

Output

Leave a Comment:

2 comments
Android Research says March 5, 2012

Could you please share the full source code, a .zip achive for example?
I think I’m missing something…

Reply
vaishali says February 2, 2013

nice tuts u have uploaded for animation, can u pls lemme know where can i download it from?

Reply
Add Your Reply