Step 1:Create new android project in eclips.
File/new project/android project/waveLayoutActivity.
Step 2:Create wave_layout.xml and wave_scale.xml in @res/anim
wave_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:rowDelay="75%"
android:columnDelay="0%"
android:directionPriority="none"
android:animation="@anim/wave_scale" />
wave_scale.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="100" />
<scale android:fromXScale="0.5" android:toXScale="1.5"
android:fromYScale="0.5" android:toYScale="1.5" android:pivotX="50%"
android:pivotY="50%" android:duration="200" />
<scale android:fromXScale="1.5" android:toXScale="1.0"
android:fromYScale="1.5" android:toYScale="1.0" android:pivotX="50%"
android:pivotY="50%" android:startOffset="200" android:duration="100" />
</set>
Step 3:Edit waveLayoutActivity class as like
package com.empmark.wavelayout;
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 WaveLayoutActivity extends Activity {
private List<ResolveInfo> 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(WaveLayoutActivity.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;
}
}
}
Step 4:no need to edit anything in androidmanifest.xml.
Step 5:save project and run in emulator.
Step 6:You'll get an output like as...
File/new project/android project/waveLayoutActivity.
Step 2:Create wave_layout.xml and wave_scale.xml in @res/anim
wave_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:rowDelay="75%"
android:columnDelay="0%"
android:directionPriority="none"
android:animation="@anim/wave_scale" />
wave_scale.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="100" />
<scale android:fromXScale="0.5" android:toXScale="1.5"
android:fromYScale="0.5" android:toYScale="1.5" android:pivotX="50%"
android:pivotY="50%" android:duration="200" />
<scale android:fromXScale="1.5" android:toXScale="1.0"
android:fromYScale="1.5" android:toYScale="1.0" android:pivotX="50%"
android:pivotY="50%" android:startOffset="200" android:duration="100" />
</set>
Step 3:Edit waveLayoutActivity class as like
package com.empmark.wavelayout;
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 WaveLayoutActivity extends Activity {
private List<ResolveInfo> 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(WaveLayoutActivity.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;
}
}
}
Step 4:no need to edit anything in androidmanifest.xml.
Step 5:save project and run in emulator.
Step 6:You'll get an output like as...
No comments:
Post a Comment