在Android的地方观看里面的FrameLayout [英] Place view inside FrameLayout in Android

查看:133
本文介绍了在Android的地方观看里面的FrameLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个视图内的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.

这篇关于在Android的地方观看里面的FrameLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆