简体   繁体   中英

how to set LinearLayout in bottom of FrameLayout programmatically?

I have this code :

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

How to set the LinearLayout in the buttom of the FrameLayout ?

Try this,

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

params.gravity = Gravity.BOTTOM;

game.addView(GameWidgets, params); 

Use this code:

FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM
                    | Gravity.CENTER_HORIZONTAL);
game.addView(GameWidgets, p);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM