在Android的地方观看里面的FrameLayout里面、地方、Android、FrameLayout

由网友(我已绝版请珍惜)分享简介:我想添加一个视图内的FrameLayout编程,并将其放置在一个特定的宽度和高度布局中的特定点。是否的FrameLayout支持呢?如果不是这样,我应该使用一个中间的ViewGroup实现这一目标?I want to add a view inside a FrameLayout programmatically a...

我想添加一个视图内的FrameLayout编程,并将其放置在一个特定的宽度和高度布局中的特定点。是否的FrameLayout支持呢?如果不是这样,我应该使用一个中间的ViewGroup实现这一目标?

I want to add a view inside a FrameLayout programmatically and to place it in a specific point within the layout with a specific width and height. Does FrameLayout support this? If not, should I use an intermediate ViewGroup to achieve this?

int x; // Can be negative?
int y; // Can be negative?
int width;
int height;
View v = new View(context);
// v.setLayoutParams(?); // What do I put here?
frameLayout.addView(v);

我最初的想法是一个AbsoluteLayout添加到的FrameLayout并将AbsoluteLayout内的视图。不幸的是我刚刚发现AbsoluteLayout是德precated。

My initial idea was to add an AbsoluteLayout to the FrameLayout and place the view inside the AbsoluteLayout. Unfortunately I just found out that AbsoluteLayout is deprecated.

任何指针将大大AP preciated。谢谢你。

Any pointers will be much appreciated. Thanks.

推荐答案

这是真的,用的FrameLayout所有的孩子都盯住屏幕的左上角,但你仍然有其设置填充一些控制。如果设置不同的填充值不同的孩子,他们会出现在在的FrameLayout不同的地方。

It's true that with FrameLayout all children are pegged to the top left of the screen, but you still have some control with setting their padding. If you set different padding values to different children, they will show up at different places in the FrameLayout.

阅读全文

相关推荐

最新文章