我想在FrameLayout中以编程方式添加一个视图,并将其放置在布局中的特定位置,具有特定的宽度和高度。 FrameLayout支持这个吗?如果不支持,我应该使用中间的ViewGroup来实现吗?
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已被弃用。
非常感谢任何提示。