在按钮的单击回调中,创建一个ImageView对象,设置瓶子图像并将其定位。例如(我假设你的元素的名字):
ImageView iv = new ImageView(this);
iv.setImageResource(R.drawable.beerbottle);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.RelativeLayout01);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.BELOW, R.id.ButtonRecalculate);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rl.addView(iv, lp);
我没有测试过这个,记住你,但它应该给你一个好的开始。您可能需要向ImageView中添加其他参数,并且可能需要向LayoutParams添加其他参数,使其看起来更好,还可以跟踪显示多少瓶等。