Currently, I have a relative layout defined programatically
RelativeLayout layout = new RelativeLayout(this);
then I add textviews and buttons like this
layout.addView(myText, params);
layout.addView(myBtn, param);
However, this makes the entire screen fill up with my relativelayout, how do I (programatically) set only certain number of pixels(dp) take up the screen? My goal is to have like the bottom half of the screen relativelayout
Anyhelp?
EDIT: This is what I am trying to achieve ultimately : https://i.stack.imgur.com/Zsxnm.png
I think this (in XML) might help me
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
I tried converting it into java like this before I add the textviews:
parameters_layout = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
200);
layout.setLayoutParams(parameters_layout);
EDIT 2 I tried adding:
parameters_layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
parameters_layout.addRule(RelativeLayout.ALIGN_BOTTOM, RelativeLayout.TRUE);
layout.setGravity(Gravity.BOTTOM);
layout.setLayoutParams(parameters_layout);
Still no luck