我是一个新手到安卓development.Now,我想做像below.The一样的圆形图像画廊视图是,我想放大中心图像时,用户滚动从左到右,从右到左。有没有关于这方面的教程?

我想要的是被滑动的图像需要在居中时被放大。我想我可以和Gallery一起做。但android开发人员的示例并不是我想要的。:(
发布于 2010-09-25 19:13:00
如果你想放大居中选择的图像,有一种可能的方法。在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上制作动画。
谢谢,
Sen
发布于 2010-09-03 20:35:59
您可以尝试:
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;
}
}}发布于 2011-08-03 01:58:28
为此,我创建了自己的教程:http://evgeni-shafran.blogspot.com/2011/08/tutorial-custom-gallery-circular-and.html
为了让它是循环的,你需要让它认为它有很多项目,比你实际拥有的项目多得多。
然后通过使position= position % items.length,你创建了类似的东西(我将展示3个项目):1,2,3,1,2,3,1,2,3,1,2,3,3,2,3,2,3,2,2,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,2,3,1,2,3,1,2,3,->1<-,2,3,1,2,3,1,2,3,1,2,3
要将其选中:您需要覆盖setOnItemSelectedListener并操纵大小。不要忘记保存对上一个视图的引用,这样当您转到下一个视图时,您可以使其看起来规则,而不是放大。
我在上面列出的教程中实现了这两种方法
https://stackoverflow.com/questions/3633370
复制相似问题