I have two relative layouts. Both have width of fill parent and height of 100 dip. My requirement is when I click the first layout it should shrink to 50dip height and the o
Remember that the LayoutParams are use by the Parent(viewgroup of parent) in order to determine how to layout this View.
Thus for example if you have the following
LinearLayout
RelativeLayout1
RelativeLayout2
And you want to change the width or height of the RelativeLayout1 or RelativeLayout2, then you need to do something like this.
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 200);
//Get handle to RelativeLayout1 assuming it is R1, you would call
R1.setLayoutParams(lp);
You would need to do the same to change RelativeLayout2's LayoutParams also.
Is is easy to forget the hierarchy, and to assume that you need to set the layout of the child, but it is the parent that determines what attributes are supported (eg. Alignment, or gravity etc..)
Hope this helps. It has burned me a few times....