FrameLayout frameLayout = new FrameLayout(this);
LinearLayout linearLayout1= new LinearLayout(this);
LinearLayout linearLayout2= new LinearLayout(this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER_VERTICAL;
frameLayout.addView(linearLayout1, params);
how to add linearLayout2 under linearLayout1
Based on the knowledge that your code works.
Change the FrameLayout for a vertical linear layout i.e. it lays out it's children below each other.
LinearLayout parentLayout = new LinearLayout(this);
LinearLayout linearLayout1= new LinearLayout(this);
LinearLayout linearLayout2= new LinearLayout(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER_VERTICAL;
parentLayout.setOrientation(VERTICAL);
parentLayout.addView(linearLayout1, params);
parentLayout.addView(linearLayout2, 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