如何使用Gallery更快地移动图像

时间:2016-03-30 02:46:04

标签: android gallery

我在这里发布我的文件: 当我运行程序时,图像会出现,但是当我滑动它们时,它们往往会非常缓慢地滑动。我怎样才能让它更快?这是我的xml文件:

            <Gallery
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/gallery"
                android:isScrollContainer="true"/>
            <ImageView
                android:layout_width="250dp"
                android:layout_height="250dp"
                android:id="@+id/imageView"
                android:layout_centerHorizontal="true"/>




gallery.setSpacing(1);
        final GalleryImageAdapter galleryAdapter = new GalleryImageAdapter(this);
        gallery.setAdapter(galleryAdapter);

        gallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                 SelectedImage.setImageResource(galleryAdapter.mImageIds[position]);
            }
        });
    }

@Override
    public View getView(int position, View convertView, ViewGroup parent)
    {

        ImageView i = new ImageView(mContext);
        i.setImageResource(mImageIds[position]);
        i.setLayoutParams(new Gallery.LayoutParams(200, 200));
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        return i;
    }
    public Integer[] mImageIds={
            R.drawable.a,
            R.drawable.b,
            R.drawable.c
    };

0 个答案:

没有答案