package com.src;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.GridView;
public class GrideActivity extends Activity {
private GridView gallery;
private ImageAdapter adapter;
private int[] image = { R.drawable.lomoeffect_01, R.drawable.lomoeffect_02,
R.drawable.lomoeffect_03, R.drawable.lomoeffect_04,
R.drawable.lomoeffect_05 };
private int[] different = { R.drawable.selct1, R.drawable.selct2,
R.drawable.selct3, R.drawable.selct4, R.drawable.selct5 };
private int[] images = { R.drawable.lomoeffect_01,
R.drawable.lomoeffect_02, R.drawable.lomoeffect_03,
R.drawable.lomoeffect_04, R.drawable.lomoeffect_05 };
Animation animation;
private AnimationSet manimationSet;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.main);
// animation = AnimationUtils.loadAnimation(this, R.anim.gradually);
adapter = new ImageAdapter(this, images);
gallery = (GridView) findViewById(R.id.gallery);
gallery.setAdapter(adapter);
gallery.setNumColumns(5);
gallery.smoothScrollToPosition(2);
// gallery.setSelector(0);
gallery.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// arg1.startAnimation(animation);
images[position] = different[position];
if (position == 0) {
for (int i = position + 1; i < images.length; i++) {
images[i] = image[i];
}
} else if (position == images.length - 1) {
for (int i = 0; i < images.length - 1; i++) {
images[i] = image[i];
}
} else {
for (int i = 0; i < position; i++) {
images[i] = image[i];
}
for (int i = position + 1; i < images.length; i++) {
images[i] = image[i];
}
}
// AnimationSet animationSet = new AnimationSet(true);
// // animationSet.setFillEnabled(true);
// // animationSet.setFillAfter(true);
// ScaleAnimation scaleAnimation = new ScaleAnimation(1, 1.2f,1,
// 1.2f,
// Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
// 0.5f);
// animationSet.addAnimation(scaleAnimation);
// animationSet.setDuration(1000);
// arg1.startAnimation(animationSet);
//
if (position != 0 && position != 4) {
AnimationSet animationSet = new AnimationSet(true);
if (manimationSet != null && manimationSet != animationSet) {
ScaleAnimation scaleAnimation = new ScaleAnimation(2,
0.5f, 2, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(1000);
manimationSet.addAnimation(scaleAnimation);
manimationSet.setFillAfter(true);
arg1.startAnimation(manimationSet);
}
ScaleAnimation scaleAnimation = new ScaleAnimation(1, 2f,
1, 2f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(1000);
animationSet.addAnimation(scaleAnimation);
animationSet.setFillAfter(true);
arg1.startAnimation(animationSet);
manimationSet = animationSet;
} else {
if (null != manimationSet)
manimationSet.setFillAfter(false);
}
//
adapter.notifyDataSetChanged();
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
用GridView加动画写了一个滑动放大显示选中图片
共59个文件
png:26个
class:13个
xml:5个
4星 · 超过85%的资源 需积分: 10 194 下载量 28 浏览量
2012-12-19
14:36:17
上传
评论 7
收藏 491KB RAR 举报
温馨提示
用GridView加动画写了一个滑动放大显示选中图片 项目需求在制定大小区域写一个横向菜单栏,菜单栏整体不能移动,GalleryFlow画廊不能满足需求,就自己重写写了一个)划到当图片时换个图片且动画效果渐渐放大,划到下一张时候前一张用动画渐渐还原原来大小----先上个效果图,没有找到一样大小 的图就用喷笔喷了点,希望大伙原谅,咱看效果 (很多童鞋说没效果,这里提下,压缩包里是用的setOnItemSelectedListener事件,我这里是给机顶盒用的:也就是键盘加遥控器,要想有点击事件在代码添加个setOnClickListener事件代码跟setOnItemSelectedListener代码一样)
资源推荐
资源详情
资源评论
收起资源包目录
Gallery.rar (59个子文件)
Gallery
AndroidManifest.xml 682B
res
layout
gallery_item.xml 540B
main.xml 1KB
drawable-ldpi
icon.png 2KB
drawable-mdpi
icon.png 3KB
drawable-hdpi
lomoeffect_04.png 11KB
lomoeffect_05.png 10KB
selct5.png 12KB
lomoeffect_03.png 11KB
selct1.png 14KB
selct3.png 12KB
selct2.png 15KB
lomoeffect_02.png 11KB
lomoeffect_01.png 11KB
icon.png 4KB
selct4.png 12KB
drawable-xhdpi
values
strings.xml 109B
proguard.cfg 1KB
src
com
src
GridViews.java 3KB
GrideActivity.java 4KB
ImageAdapter.java 2KB
bin
classes
com
src
GridViews.class 4KB
GrideActivity$2.class 1KB
BuildConfig.class 323B
ImageAdapter.class 2KB
R.class 454B
GrideActivity.class 3KB
GrideActivity$1.class 3KB
R$layout.class 397B
R$attr.class 307B
R$id.class 426B
R$string.class 365B
R$drawable.class 702B
ImageAdapter$GalleryInfo.class 503B
dexedLibs
annotations-891e9623e997cafcd5c658ab313af6c4.jar 943B
AndroidManifest.xml 682B
res
drawable-ldpi
icon.png 2KB
drawable-mdpi
icon.png 2KB
drawable-hdpi
lomoeffect_04.png 11KB
lomoeffect_05.png 10KB
selct5.png 9KB
lomoeffect_03.png 11KB
selct1.png 10KB
selct3.png 10KB
selct2.png 10KB
lomoeffect_02.png 11KB
lomoeffect_01.png 11KB
icon.png 4KB
selct4.png 9KB
classes.dex 13KB
Gallery.apk 122KB
resources.ap_ 114KB
.classpath 364B
assets
project.properties 563B
.settings
org.eclipse.core.resources.prefs 57B
org.eclipse.jdt.core.prefs 177B
.project 843B
gen
com
src
R.java 1KB
BuildConfig.java 149B
共 59 条
- 1
骑猪看_夕阳
- 粉丝: 6
- 资源: 80
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页