Android – How to set the height and width of linear layout dynamically in android

android

I have a Linearlayout in my xml which has fill_parent for both height and width…
Now i want to dynamically change the height and width…
I tried Using

_llChooseType.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,getWindowManager().getDefaultDisplay().getHeight()-100));

But it is giving me java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
exception…

How to do it?

Best Answer

Use this..

new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,getWindowManager().getDefaultDisplay().getHeight()-100));