在FrameLayout中定位视图

时间:2012-08-25 19:22:02

标签: android

我正在尝试在我的FrameLayout中定位一个视图,但视图位于具有给定宽度和高度的topleft角落中。

/**
 * Adds a view to the window.
 */
public void AddPanel(PanelWrapper child, int Left, int Top, int Width, int Height) {
    this.window.addView(child.getObject(), new BALayout.LayoutParams(Left, Top, Width, Height));
    child.getObject().setPadding(Left, Top, 0, 0);

    for (int i=0;i<child.getNumberOfViews();i++) {
        Log.i("B4A", "View " + i);
        ViewEventListener vel = new ViewEventListener();
        vel.Initialize(this.ba, this.eventName, child.GetView(i).getObject());
    }

    ViewEventListener vel = new ViewEventListener();
    vel.Initialize(this.ba, this.eventName, child.getObject());
}

我要做的是将给定尺寸的给定位置放置视图(PanelWrapper是一个视图组)。

1 个答案:

答案 0 :(得分:0)

如果它的视图像ImageView,请尝试

android:scaleType="fitCenter"

android:gravity="center"

layout.xml中。关于android中布局的大量信息可以在这里找到:http://www.learn-android.com/2010/01/05/android-layout-tutorial/3/