�����ڵ�λ�ã���ҳ > ���� > Դ������ > ����
Android 3D��Ӱ��Ὺ��
http://www.drovik.com/      2012-11-7 11:26:52      ��Դ��CSDN����      �����

 

����Ч��ͼ��

 

 

 

 ���ִ��룺

 

public class MainActivity extends Activity implements OnItemSelectedListener{

private CustomGallery gallery;
private ImageAdapter imageAdapter;

private int[] resIds = new int[] { R.drawable.item1, R.drawable.item2,
R.drawable.item3, R.drawable.item4, R.drawable.item5,
R.drawable.item6, R.drawable.item7, R.drawable.item8,
R.drawable.item9, R.drawable.item10, R.drawable.item11,
R.drawable.item12, R.drawable.item13, R.drawable.item14,
R.drawable.item15 };

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gallery = (CustomGallery) findViewById(R.id.gallery);
gallery.setSelection(2, true);
gallery.setAnimationDuration(1000);
imageAdapter = new ImageAdapter(this);
gallery.setAdapter(imageAdapter);
gallery.setOnItemSelectedListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
// ѡ��Gallery��ij��ͼ��ʱ����ImageSwitcher����зŴ���ʾ��ͼ��

}

@Override
public void onNothingSelected(AdapterView<?> parent) {
}
public class ImageAdapter extends BaseAdapter {

int mGalleryItemBackground;

private Context mContext;

public ImageAdapter(Context context) {
mContext = context;
TypedArray typedArray = obtainStyledAttributes(R.styleable.Gallery);
mGalleryItemBackground = typedArray.getResourceId(
R.styleable.Gallery_android_galleryItemBackground, 0);
typedArray.recycle();
}

// ��1��Ľ�������һ���ܴ��ֵ�����磬Integer.MAX_VALUE
public int getCount() {
return Integer.MAX_VALUE;
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
ImageView i = createReflectedImages(mContext, resIds[position%resIds.length]);
i.setLayoutParams(new CustomGallery.LayoutParams(120, 100));
i.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
// ���õĿ����,��ֹͼ������ת��ʱ����־��
BitmapDrawable drawable = (BitmapDrawable) i.getDrawable();
drawable.setAntiAlias(true);
return i;
}
}

/**
 * ΪͼƬ���ӵ�Ӱ
 * @param mContext
 * @param imageId
 * @return
 */
public ImageView createReflectedImages(Context mContext, int imageId) {
Bitmap originalImage = BitmapFactory.decodeResource(
mContext.getResources(), imageId);
final int reflectionGap = 4;
int width = originalImage.getWidth();
int height = originalImage.getHeight();

Matrix matrix = new Matrix();
matrix.preScale(1, -1);

Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0,
height / 2, width, height / 2, matrix, false);

Bitmap bitmapWithReflection = Bitmap.createBitmap(width,
(height + height / 2), Config.ARGB_8888);

Canvas canvas = new Canvas(bitmapWithReflection);
canvas.drawBitmap(originalImage, 0, 0, null);

Paint deafaultPaint = new Paint();
canvas.drawRect(0, height, width, height + reflectionGap, deafaultPaint);
canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);

Paint paint = new Paint();
LinearGradient shader = new LinearGradient(0,
originalImage.getHeight(), 0, bitmapWithReflection.getHeight()
+ reflectionGap, 0x70ffffff, 0x00ffffff,
TileMode.MIRROR);

paint.setShader(shader);
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
+ reflectionGap, paint);

ImageView imageView = new ImageView(mContext);
imageView.setImageBitmap(bitmapWithReflection);

return imageView;
}

}

 

���̴������ص�ַ��

http://www.drovik.com/android/demo/3DGalleryDemo.rar

 

 

 

��������
��������(3)
cartier watch replicas  ������  2015-3-30 20:09:41
Nice post. I��ve learned more from your aticle.Thanks cartier watch replicas http://jiayouyumaoqiu.com/bbs/forum.php?mod=viewthread&tid=40733&extra=
�륤�����ȥ�ؔ����ֱ��  ������  2015-7-8 4:23:44
�륤�����ȥ�ؔ����ֱ�� http://www.sinopromotion.com/bottoms.asp?qb80-xq3me.htm, �륤�����ȥ�Хå������� http://www.sinopromotion.com/bottoms.asp?hq62-fv7it.htm, �륤�����ȥ�ؔ������ץ��� http://www.sinopromotion.com/bottoms.asp?by36-hg2ac.htm, �륤�����ȥ���ߥ���������Хå� http://www.sinopromotion.com/bottoms.asp?ia66-ey4ch.htm, �륤�����ȥ�ؔ���й�Ʒ http://www.sinopromotion.com/bottoms.asp?ai94-cl4ri.htm,
www.successmens.com  ������  2015-9-16 1:15:34
2010 Shoes Trend www.successmens.com http://www.successmens.com/
���� *
�������� *
��֤�� *ͼƬ�����壿������µõ���֤��