我正在制作一个 android 应用程序,我必须在其中旋转网格视图中的图像。我写了以下代码:
public boolean onTouch(View v, MotionEvent me) {
.............
int position = parent.pointToPosition(x, y);
switch(me.getAction())
{
case MotionEvent.ACTION_DOWN :
//int z = fPosition(x,y);
sr = position;
doRotation(v,position);
//startAnimation(v);
//Toast.makeText(GameActivity.this, "down "+position,Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_UP :
//popUp.dismiss();
ds = position;
images.cPositions(sr,ds);
images.notifyDataSetChanged();
//int z1 = fPosition(x,y);
//Toast.makeText(GameActivity.this, "up " + position, Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_MOVE :
//Toast.makeText(GameActivity.this, "move", Toast.LENGTH_SHORT).show();
break;
}
return true;
}
void doRotation(View v, int position) {
final ImageView im;
final RotateAnimation rAnim;
ViewGroup vg = (ViewGroup) findViewById(R.id.mlinear);
rAnim = new RotateAnimation(0f,360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rAnim.setStartOffset(0);
rAnim.setDuration(2000);
rAnim.setFillAfter(true);
rAnim.setFillEnabled(true);
v.startAnimation(rAnim);
}
我在 android 2.2(8 级)上,它正在做的是它的旋转整个网格视图,我想在图像上旋转。只想知道如何在网格视图中获取图像的图像视图..