I currently have a relative layout defined programmatically
RelativeLayout layout = new RelativeLayout(this);
then i add text images and buttons like this
layout.addView(myText, params); layout.addView(myBtn, param);
However, it makes the whole screen fill up with my relativity, how do I (programmatically) set only a certain number of pixels (dp) while occupying the screen? My goal is to have both the lower half of the screen relativelayout
Anyhelp?
EDIT: This is what I am trying to achieve in the end: http://i.imgur.com/n1ckBN7.png
I think this (in XML) can help me
<RelativeLayout android:layout_width="match_parent" android:layout_height="200dp">
I tried converting it to java like this before adding text images:
parameters_layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 200); layout.setLayoutParams(parameters_layout);
EDIT 2 I tried to add:
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);
Not lucky yet
source share