如何单独移动每个矩形?
我有五个形状可绘制矩形,我必须将矩形设置为(-20,-15,-10,-5,0)度的角度。每个矩形都有四种颜色的阴影。现在我需要一个一个地为每个矩形设置动画,如果用户从左到右拖动,则顶部矩形从左到右移动。
问题是,我无法单独移动每个矩形。我如何分别识别和实现每个矩形?
这是我必须做的示例快照。 http://postimage.org/image/13sa96sbo/
public ColorFanDraw(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvasObject) {
int x = 100;
int y = 50;
int width = 70;
int convasSize =200;
Paint thePaint = new Paint();
thePaint.setColor(mTouchedColor-200);
canvasObject.rotate(-15, centerX,centerY);
canvasObject.drawRect(new Rect(x,y,x+width,y+convasSize), thePaint);
thePaint.setColor(mTouchedColor-50);
canvasObject.rotate(10, centerX,centerY);
canvasObject.drawRect(new Rect(x,y,x+width,y+convasSize), thePaint);
canvasObject.rotate(10, centerX,centerY);
thePaint.setColor(mTouchedColor);
canvasObject.drawRect(new Rect(x,y,x+width,y+convasSize), thePaint);
rotation = AnimationUtils.loadAnimation(contextObj,
R.anim.view_transition_in_left);
ImageView img = new ImageView(contextObj);
img.startAnimation(rotation);
}
I have five shape draw able rectangular, I have to set the rectangle at angle of (-20,-15,-10,-5,0)Degree. Each Rectangular have four colors shade. Now I need to animate each rectangle one by one and if user drag left to right then top rectangle moves to left to right.
Problem is, I can’t move each rectangle separately. How I can identify and implement each rectangle separately?
Here sample snapshot that i have to do.
http://postimage.org/image/13sa96sbo/
public ColorFanDraw(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvasObject) {
int x = 100;
int y = 50;
int width = 70;
int convasSize =200;
Paint thePaint = new Paint();
thePaint.setColor(mTouchedColor-200);
canvasObject.rotate(-15, centerX,centerY);
canvasObject.drawRect(new Rect(x,y,x+width,y+convasSize), thePaint);
thePaint.setColor(mTouchedColor-50);
canvasObject.rotate(10, centerX,centerY);
canvasObject.drawRect(new Rect(x,y,x+width,y+convasSize), thePaint);
canvasObject.rotate(10, centerX,centerY);
thePaint.setColor(mTouchedColor);
canvasObject.drawRect(new Rect(x,y,x+width,y+convasSize), thePaint);
rotation = AnimationUtils.loadAnimation(contextObj,
R.anim.view_transition_in_left);
ImageView img = new ImageView(contextObj);
img.startAnimation(rotation);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在将矩形对象绘制到画布上之前,您需要将它们存储在变量中。
等等。
然后,无论您在哪里制作动画,都可以引用各个矩形。
You would need to store the rectangle objects in a variable before you draw them onto the Canvas.
and so on.
Then you can refer to the individual rectangles wherever you are doing your animation.