[英]Android positioning ImageView
I am too tired to figure this out, so pls help. 我太累了,无法解决这个问题,所以请帮忙。
I have an image view in a RelativeLayout and i need to position it during run-time at the top of the screen and in the middle. 我在RelativeLayout中有一个图像视图,我需要在运行时将其放置在屏幕顶部和中间。 (so top-middle).
(如此居中)。 I figured out how to place it at the top:
我想出了如何将其放在顶部:
params = new RelativeLayout.LayoutParams(obWidth, obHeight);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
But now i only need to position in to the left a bit so it's in the middle of the screen. 但是现在我只需要稍微向左移动一点,就在屏幕中间。
BTW: I don't want to use margins. 顺便说一句:我不想使用边距。
也许这个吗?
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.