android Gallery组件实现的iPhone图片滑动效果实例
作者:junjie 时间:2022-09-27 06:38:17
实现的效果图,可左右滑动:
一、先在将Gallery标签放入:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Gallery
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
二、Gallery 需要用Adapter来填充,先从BaseAdapter中派生一个ImageAdapter出来
public class ImageAdapter extends BaseAdapter
{
private Context context;
private int[] MyImageIDs =
{ R.drawable.icon, R.drawable.carlogo_52design_09,
R.drawable.carlogo_52design_13, R.drawable.carlogo_52design_19,
R.drawable.carlogo_52design_24, R.drawable.carlogo_52design_27,
R.drawable.carlogo_52design_29, R.drawable.carlogo_52design_31,
R.drawable.carlogo_52design_34, R.drawable.carlogo_52design_36 };
public ImageAdapter(Context context)
{
// TODO Auto-generated constructor stub
this.context = context;
}
@Override
public int getCount()
{
// TODO Auto-generated method stub
return MyImageIDs.length;
}
@Override
public Object getItem(int arg0)
{
// TODO Auto-generated method stub
return arg0;
}
@Override
public long getItemId(int position)
{
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
ImageView i = new ImageView(this.context);
i.setImageResource(this.MyImageIDs[position]);
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setLayoutParams(new Gallery.LayoutParams(120, 120));
return i;
}
}
标签:android,Gallery,iPhone,图片滑动效果
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
IDEA与模拟器安装调试失败的处理方法:INSTALL_PARSE_FAILED_NO_CERTIFICATES
2022-08-25 13:57:53
![](https://img.aspxhome.com/file/2023/2/75462_0s.png)
C#中内联函数的用法介绍
2023-04-18 18:29:18
Android入门简单实例
2021-07-26 16:34:04
![](https://img.aspxhome.com/file/2023/1/75411_0s.jpg)
spring boot使用thymeleaf为模板的基本步骤介绍
2023-12-13 15:07:23
![](https://img.aspxhome.com/file/2023/9/98699_0s.png)
java中类加载与双亲委派机制详解
2023-12-07 06:34:53
![](https://img.aspxhome.com/file/2023/6/94296_0s.webp)
Android下拉列表选项框及指示箭头动画
2022-09-28 04:08:15
![](https://img.aspxhome.com/file/2023/7/90157_0s.png)
spring中bean的生命周期详解
2021-11-29 23:31:02
C# 鼠标穿透窗体功能的实现方法
2021-09-26 04:24:38
Android 基于Bitmap的四种图片压缩方式
2022-06-13 11:50:21
![](https://img.aspxhome.com/file/2023/7/120177_0s.jpg)
Android仿百度图片查看功能
2023-09-26 07:50:24
![](https://img.aspxhome.com/file/2023/8/85448_0s.jpg)
Android自定义控件之继承ViewGroup创建新容器
2023-06-15 08:50:11
![](https://img.aspxhome.com/file/2023/8/98688_0s.jpg)
如何在c语言下关闭socket
2021-12-26 10:22:46
Java解码H264格式视频流中的图片
2023-11-24 23:58:24
浅谈Mybatis通用Mapper使用方法
2023-02-15 17:46:52
Unity UI实现拖拽旋转
2023-04-10 06:44:59
![](https://img.aspxhome.com/file/2023/9/74839_0s.jpg)
Android中自定义ImageView添加文字说明详解
2022-10-23 18:39:27
![](https://img.aspxhome.com/file/2023/4/126664_0s.png)
基于C#调用c++Dll结构体数组指针的问题详解
2021-12-10 23:16:41
Java实现的计时器【秒表】功能示例
2023-11-10 21:24:50
![](https://img.aspxhome.com/file/2023/1/59051_0s.gif)
Android刷新加载框架详解
2022-11-20 05:41:10
java Hibernate多对多映射详解及实例代码
2023-07-02 07:24:40
![](https://img.aspxhome.com/file/2023/2/61052_0s.png)