图像放置在Android中的图像上

时间:2012-05-03 17:31:07

标签: android image android-layout imageview

我试图在android中的另一个现有图像上放置一个图像。这是游戏计划。首先,用户将选择一个按钮,然后该按钮将告诉程序将精灵/图像填充到主图像上的固定位置。一旦图像被设置,用户就可以在当前它们之上点击另一个图像的按钮(目标是两个图像,可以选择改变它们的大小,x和y位置。我只使用android 2.1平台!选择按钮和描述活动的文本是线性布局。

1 个答案:

答案 0 :(得分:0)

您应该使用RelativeLayout,然后您可以使用参数设置位置,保证金等。 像这样的东西:

//this is your fist item
r1.setImageResource(R.drawable.myimage);

//this is the second item
r2.setImageResource(R.drawable.myimage2);

RelativeLayout.LayoutParams imageParams=
new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
imageParams.setMargins(1, 1, 1, 1);
imageParams.addRule(RelativeLayout.BELOW,r1.getId());
addView(r2,imageParams);