用gallery展示图片,实现中间图片稍大,两边较小的效果
来源:互联网 发布:高保真播放软件 编辑:程序博客网 时间:2024/04/18 13:39
http://www.cnblogs.com/ProgramBull/archive/2012/02/06/2339727.html
用gallery展示图片,实现中间图片稍大,两边较小的效果
实现原理:在onItemSelected事件中,选中galerry中的图片时,把选中的图片放大,把没有选中的缩小。
以下是关键代码
1 public void onItemSelected(AdapterView<?> parent, View view, int position,
2 long id) {
3 // 选中Gallery中某个图像时,放大显示该图像
4 ImageView imageview = (ImageView)view;
5 ((ImageView) view).setImageDrawable((Drawable) product_image_list.get(position));
6 view.setLayoutParams(new Gallery.LayoutParams(520 / 2, 318 / 2));
7 title.setText((String)product_title.get(position));
8 info.setText((String)product_info.get(position));
9 for(int i=0; i<parent.getChildCount();i++){
10 //缩小选中图片旁边的图片
11 ImageView local_imageview = (ImageView)parent.getChildAt(i);
12 if(local_imageview!=imageview){
13 local_imageview.setLayoutParams(new Gallery.LayoutParams(520/4, 318/4));
14 local_imageview.setScaleType(ImageView.ScaleType.FIT_CENTER);
15 }
16 }
17 }
18
19 public void onNothingSelected(AdapterView<?> parent)
20 {
21 }
22
23 public class ImageAdapter extends BaseAdapter
24 {
25 int mGalleryItemBackground;
26 private Context mContext;
27
28 public ImageAdapter(Context context)
29 {
30 mContext = context;
31 // TypedArray typedArray = obtainStyledAttributes(R.styleable.Gallery);
32 // mGalleryItemBackground = typedArray.getResourceId(
33 // R.styleable.Gallery_android_galleryItemBackground, 0);
34 }
35
36 public int getCount()
37 {
38 return product_image_list.size();
39 }
40
41 public Object getItem(int position)
42 {
43 return position;
44 }
45
46 public long getItemId(int position)
47 {
48 return position;
49 }
50
51 public View getView(int position, View convertView, ViewGroup parent)
52 {
53 ImageView imageView = new ImageView(mContext);
54 imageView.setLayoutParams(new Gallery.LayoutParams(520/4, 318/4));//默认都是大图
55 imageView.setImageDrawable((Drawable) product_image_list.get(position));
56 imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
57 return imageView;
58 }
59 }
2 long id) {
3 // 选中Gallery中某个图像时,放大显示该图像
4 ImageView imageview = (ImageView)view;
5 ((ImageView) view).setImageDrawable((Drawable) product_image_list.get(position));
6 view.setLayoutParams(new Gallery.LayoutParams(520 / 2, 318 / 2));
7 title.setText((String)product_title.get(position));
8 info.setText((String)product_info.get(position));
9 for(int i=0; i<parent.getChildCount();i++){
10 //缩小选中图片旁边的图片
11 ImageView local_imageview = (ImageView)parent.getChildAt(i);
12 if(local_imageview!=imageview){
13 local_imageview.setLayoutParams(new Gallery.LayoutParams(520/4, 318/4));
14 local_imageview.setScaleType(ImageView.ScaleType.FIT_CENTER);
15 }
16 }
17 }
18
19 public void onNothingSelected(AdapterView<?> parent)
20 {
21 }
22
23 public class ImageAdapter extends BaseAdapter
24 {
25 int mGalleryItemBackground;
26 private Context mContext;
27
28 public ImageAdapter(Context context)
29 {
30 mContext = context;
31 // TypedArray typedArray = obtainStyledAttributes(R.styleable.Gallery);
32 // mGalleryItemBackground = typedArray.getResourceId(
33 // R.styleable.Gallery_android_galleryItemBackground, 0);
34 }
35
36 public int getCount()
37 {
38 return product_image_list.size();
39 }
40
41 public Object getItem(int position)
42 {
43 return position;
44 }
45
46 public long getItemId(int position)
47 {
48 return position;
49 }
50
51 public View getView(int position, View convertView, ViewGroup parent)
52 {
53 ImageView imageView = new ImageView(mContext);
54 imageView.setLayoutParams(new Gallery.LayoutParams(520/4, 318/4));//默认都是大图
55 imageView.setImageDrawable((Drawable) product_image_list.get(position));
56 imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
57 return imageView;
58 }
59 }
- 用gallery展示图片,实现中间图片稍大,两边较小的效果
- UICollectionViewCell水平缩放,中间大两边小效果的实现
- ViewPager中间大两边小效果的实现
- Gallery实现图片的画廊展示
- RecycleView实现Gallery画廊效果,中间放大两边缩小
- ViewPager实现Gallery的画廊效果 突显中间 虚化两边的界面
- ImageSwitcher gallery 实现图片展示
- Android 用Gallery和ImageSwicher实现画廊效果,展示图片+完整源代码
- Android利用gallery实现图片连动的效果
- 使用Gallery来实现图片的3D效果
- RecycleView实现的Gallery画廊效果(图片制作成圆角)
- ViewPager 实现 Galler 效果, 中间大图显示,两边小图展示
- ViewPager 实现 Galler 效果, 中间大图显示,两边小图展示(优化篇)
- android 用ImageSwitcher+Gallery实现图片浏览效果
- iOS-图片两边拉伸,中间保持不变
- 实现图片缩放的Gallery
- 用Gallery(画廊)做的图片自动切换(可用作广告图片展示)
- iOS 开发 图片缩略图的生成,展示图片中间一部分
- TimeSpan的用法
- 我的积分怎么都没了?
- QLExpress脚本语言技术讲解(3) -----QL的性能描述
- Windows2008 64位系统asp连接access数据库解决方法
- 最近遇到问题
- 用gallery展示图片,实现中间图片稍大,两边较小的效果
- [探讨]不靠谱的软件开发工期预估
- 2012-2-20
- iPhone/iPad开发扎记2012/02/20
- java学习5---Java 的多线程,程序、进程和线程的概念
- usaco 1.3.3 Calf Flac
- 2-20 Android 简单MediaPlayer编写(五)
- Android的MediaRecorder架构介绍
- 同一个进程使用pipe(管道)的例子