手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android Gallery组件实现的iPhone图片滑动效果实例
android Gallery组件实现的iPhone图片滑动效果实例
摘要:实现的效果图,可左右滑动:一、先在将Gallery标签放入:复制代码代码如下:二、Gallery需要用Adapter来填充,先从BaseAd...

实现的效果图,可左右滑动:

android Gallery组件实现的iPhone图片滑动效果实例1

一、先在将Gallery标签放入:

复制代码 代码如下:<"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 程序应用的生命周期

Android 使用Gallery实现3D相册(附效果图+Demo源码)

Android从服务器获取图片的实例方法

自定义RadioButton和ViewPager实现TabHost带滑动的页卡效果

Android 软件自动更新功能实现的方法

Android实现宫格图片连续滑动效果

android 实现圆角图片解决方案

Android中实现水平滑动(横向滑动)ListView示例

android 引导界面的实现方法

android 比较靠谱的图片压缩

精品推荐
分类导航