I have a dynamic layout and I have a button. How can I set the property layout_alignParentBottom
to that button so that it would appear in the bottom of my relative layout?
Or do you know another way?
This will only work if your layout is a RelativeLayout, as other ViewGroups don't understand alignParentBottom.
RelativeLayout layout = findViewById(R.id.my_relative_layout);
Button button = new Button(this); // your button
lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // You might want to tweak these to WRAP_CONTENT
lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout.addView(button, lp);
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