实现的效果图,可左右滑动:
一、先在将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图片滑动效果实例全部内容,希望文章能够帮你解决android Gallery组件实现的iPhone图片滑动效果实例所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)