I came across this link :
Assign width to half available screen width declaratively
How to do the same in relative layout? Here\'s the code: Trying linea
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
plannerEditLayout = (RelativeLayout) findViewById(R.id.plannerLayoutEdit);
plannerEditLayout.setGravity(Gravity.CENTER_VERTICAL);
plannerEditLayout.setLayoutParams(new RelativeLayout.LayoutParams(
(width / 2), height));
I use the same code for LinearLayout. Havent tried it out myslef for RelativeLayout. Give it a shot. Comment if it doesn't work.