title: Dynamically changing the linearlayout width or height on Android
body: <p>I am trying to change linear layout or any other widget width or height dynamically but throwing exception.</p>
  
  <p>My layout is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/abc"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      &gt;
  &lt;TextView   
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="ghghjkgj ghjg hjgj ghj g hjgjgh jhg "
      /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and My activity is:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          LinearLayout ll = (LinearLayout)findViewById(R.id.abc);
          ll.setLayoutParams(new LinearLayout.LayoutParams(30,60));
      }
  </code></pre>
  
  <p>Throwing following exception:</p>
  
  <pre><code>E/AndroidRuntime(16052): java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
  E/AndroidRuntime(16052):    at android.widget.FrameLayout.onLayout(FrameLayout.java:288)
  E/AndroidRuntime(16052):    at android.view.View.layout(View.java:7035)
  E/AndroidRuntime(16052):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
  E/AndroidRuntime(16052):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
  E/AndroidRuntime(16052):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
  E/AndroidRuntime(16052):    at android.view.View.layout(View.java:7035)
  E/AndroidRuntime(16052):    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
  E/AndroidRuntime(16052):    at android.view.View.layout(View.java:7035)
  E/AndroidRuntime(16052):    at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
  E/AndroidRuntime(16052):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
  E/AndroidRuntime(16052):    at android.os.Handler.dispatchMessage(Handler.java:99)
  E/AndroidRuntime(16052):    at android.os.Looper.loop(Looper.java:123)
  E/AndroidRuntime(16052):    at android.app.ActivityThread.main(ActivityThread.java:4627)
  E/AndroidRuntime(16052):    at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(16052):    at java.lang.reflect.Method.invoke(Method.java:521)
  E/AndroidRuntime(16052):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  E/AndroidRuntime(16052):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  E/AndroidRuntime(16052):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>So how can I change the dimensions dynamically?</p>