我是新手到Android development.Now我想这样做画廊观为圆形像图像below.The事情之一是,我想放大的中心图像时用户滚动由左到右,右到左。是否有任何教程是什么?

“在这里输入的图像描述” 我要的是虽然它在中心被放大这就是被偷走需要的图像。我以为我可以与画廊做。但是从Android开发者的例子是不是我想要的。 :(

有帮助吗?

解决方案

,点击 如果你想放大的中心选定的图像有一种可能的方式。 在您onItemSelected方法,只需拨打一个动画放大的对象。画廊的特性是,它始终是中心锁定。因此,中心元素将始终选择。 希望将工作..

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false"
    android:fillAfter="true"
>
<scale 
       android:fromXScale="1.0"
       android:toXScale="1.50"
       android:fromYScale="1.0"
       android:toYScale="1.50"
       android:duration="600"
       android:pivotX="50%"
       android:pivotY="50%"
       android:fillAfter="true"/>

</set>

也请记住,你将不得不存储先前视图时,该元件是由中心应该投入到正常大小搬走。

所以,你可以有两种观点 - prevView和currView结果 请在currView动画。

谢谢,结果 森

其他提示

遵守前面尝试:

public class TestGallery extends Activity {
/** Called when the activity is first created. */
private Integer[] mImageIds = { R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4 }; 

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Gallery g = (Gallery) findViewById(R.id.gallery); 
    g.setAdapter(new ImageAdapter(this)); 

    g.setOnItemClickListener(new OnItemClickListener() { 
        public void onItemClick(AdapterView parent, View v, int position, long id) { 
            if (position >= mImageIds.length) { 
                position = position % mImageIds.length; 
            } 
            Toast.makeText(TestGallery.this, "" + position, Toast.LENGTH_SHORT).show(); 
        } 
    }); 

}

public class ImageAdapter extends BaseAdapter { 
    int mGalleryItemBackground; 
    private Context mContext; 

    public ImageAdapter(Context c) { 
        mContext = c; 
        TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); 
        mGalleryItemBackground = a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0); 

        a.recycle(); 
    } 

    public int getCount() { 
        return Integer.MAX_VALUE; 
    } 

    public Object getItem(int position) { 
        if (position >= mImageIds.length) { 
            position = position % mImageIds.length; 
        } 
        return position; 
    } 

    public long getItemId(int position) { 
        if (position >= mImageIds.length) { 
            position = position % mImageIds.length; 
        } 
        return position; 
    } 

    public View getView(int position, View convertView, ViewGroup parent) { 
        ImageView i = new ImageView(mContext); 
        if (position >= mImageIds.length) { 
            position = position % mImageIds.length; 
        } 
        i.setImageResource(mImageIds[position]); 
        i.setLayoutParams(new Gallery.LayoutParams(80, 80)); 
        i.setScaleType(ImageView.ScaleType.FIT_XY); 
        i.setBackgroundResource(mGalleryItemBackground); 
        return i; 
    } 

    public int checkPosition(int position) { 
        if (position >= mImageIds.length) { 
            position = position % mImageIds.length; 
        } 
        return position; 
    } 
}}

我创造了我自己的教程如下: http://evgeni-shafran.blogspot.com /2011/08/tutorial-custom-gallery-circular-and.html

有关它是圆的,你需要使它认为它有一个项目很多,多了很多,那么你真的有。

然后通过使位置=位置%items.length你创造这样(我会告诉它3项):1,2,3,1,2,3,1,2,3,1,2, 3,1,2,3,1,2,3,1,2,3 然后去中间所以即使滚动很多,他不会来接近结束。 1,2,3,1,2,3,1,2,3, - >的 1 < - ,2,3,1,2,3,1,2,3,1,2 ,3

有关它被选择:您需要重写setOnItemSelectedListener和操作的大小。不要忘记参考保存到最后的视图,以便当你到下一个,你可以使它看起来正规,不扩大。

我实现两者的这是上面列出我的教程

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top