2011-07-16 54 views
1

我有一个应用程序,我必须在屏幕的不同部分放置一组ImageView,每个ImageView通过指定坐标(x,y)放置在一个位置。的android?如果是这样,请让我知道如何去做。Android:根据需要放置视图

回答

0

这是可能的通过在他们的xml布局中设置位置在一个绝对布局。但是,如果您想要动态更改代码中图像视图的位置,则只能通过设置边距和填充来左右移动它们并上/下来更改位置。以下内容将接收图像视图的布局参数,以便您可以更改视图的边距。

ImageView image; 
MarginLayoutParams params = (MarginLayoutParams)image.getLayoutParams(); 
param.setMargins(int left, int top, int right, int bottom);