开发者

Android: Placing Views as required

I have an application where I have to place a set of ImageViews in different parts of the screen, each ImageView placed at a posi开发者_JS百科tion by specifying the co-ordinates(x,y) Is this possible in android? If so, pls let me know how to do it.


It is possible but not recommended since it doesn't work well across resolutions/densities/aspect-ratios.


This is possible by setting the positions in their xml layout in an absolutelayout. Though, if you want to change the position of the imageview in your code dynamically you can only change the positions by setting their margins and padding to move them left/right and up/down. The following receives the layout params of the imageviews so that you can change the views' margins.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜