views:

12

answers:

0

Hi All,

I have a layout xml file with a linear layout. One of the children is again a ViewGroup Relative layout. In my java code i want to change the width of this child Viewgroup for my requirements. I tried this

enter code here

    ViewGroup childViewGroup = (LinearLayout)findViewById(childViewGroup);
    LayoutParams l = childViewGroup.getLayoutParams();
    l.width = 360; 
    childViewGroup .setLayoutParams(l);

I couldn't do this because findViewById(childViewGroup) doesn't fetch ViewGroups it does only for Views.

Note: I cant define a whole new layout.xml for this minor requirement since it is huge layout file and might cause performance overhead. I wanted to just change the width of the child view group in my java activity code.

Thanks in advance for your help.