在Android中,我想通过从中心点添加每个花瓣来绘制花朵。我在ImageView上使用了setRotation,但每个花瓣的中心点不同。(我的意思是花的中心点)有人可以看一下我的代码并建议我进行更正吗?谢谢。
我得到的图片是这样的:
(注:该内容为HTML代码,已被翻译)
int angle=0;
int ypos=500;
int xpos=500;
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ln1);
for(int i=0;i<10;i++)
{
ImageView image = new ImageView(this);
image.setLayoutParams(new android.view.ViewGroup.LayoutParams(150,400));
image.setX(xpos);
image.setY(ypos);
image.setPadding(-7,-30,-10,0);
image.setPivotX(1.0f);
image.setScaleX(1.5f);
image.setScaleY(1.5f);
image.setImageResource(R.drawable.petal);
image.setRotation(image.getRotation() + angle);
angle=angle+36;
layout.addView(image);
}
我得到的图片是这样的:
(注:该内容为HTML代码,已被翻译)
setRotation
之前增加了角度,那么我会期望看到这张图片。而且,我猜想图像中的花瓣本身是“直立”的,而不是原始图像本身被旋转了? - S.L. Barth