10

我有这个代码:

         FrameLayout game = new FrameLayout(this);
         LinearLayout gameWidgets = new LinearLayout (this);
         game.addView(gameWidgets);

如何在 FrameLayout 的底部设置 LinearLayout ?

4

2 回答 2

20

尝试这个,

FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);

params.gravity = Gravity.BOTTOM;

game.addView(GameWidgets, params); 
于 2013-07-08T10:10:03.913 回答
5

使用此代码:

FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM
                    | Gravity.CENTER_HORIZONTAL);
game.addView(GameWidgets, p);
于 2013-07-08T10:10:29.090 回答