how to set LinearLayout in bottom of FrameLayout programmatically?

Ala Aga picture Ala Aga · Jul 8, 2013 · Viewed 7.4k times · Source

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 ?

Answer

Donald Zhang picture Donald Zhang · Jul 8, 2013

Try this,

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

params.gravity = Gravity.BOTTOM;

game.addView(GameWidgets, params);