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 ?
If you want to add Buttons to the bottom of your android layout XML file you can achieve it using attribute layout_gravity on LinearLayout or TableRow layout. Below your Parent Layout tag add a LinearLayout or TableRow with attribute android:layout_gravity="bottom".
You can specify the gravity as center_horizontal, center_vertical and center (which centers both horizontally and vertically). On the child views of the LinearLayout you can specify the layout_gravity property, which also supports center_horizontal, center_vertical and center.
FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.
Android Framelayout is a ViewGroup subclass that is used to specify the position of multiple views placed on top of each other to represent a single view screen.
Try this,
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM;
game.addView(GameWidgets, params);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With