title: How to set programatically height and width to framelayout in android
body: <p>I want to set height and width for framelayout , if give values in java code using setlayoutparams its showing very small box, but in XML its showing properly.</p>
  
  <p>This is my java code</p>
  
  <pre><code> FrameLayout frameLayout2= (FrameLayout) light.findViewById(R.id.frameLayout2);
   ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(300, 300);
   frameLayout2.setLayoutParams(lp);
  </code></pre>
  
  <p><em>this is my xml:</em>
  Note:Constraint layout is my parent</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".LightPlaceFragment"
      tools:layout_editor_absoluteY="81dp"
      tools:layout_editor_absoluteX="0dp"
      android:background="@color/colorAccent"&gt;
  
  
  
      &lt;FrameLayout
          android:layout_width="300dp"
          android:layout_height="300dp"
          android:layout_marginRight="8dp"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintBottom_toBottomOf="parent"
          android:layout_marginBottom="8dp"
          android:layout_marginLeft="8dp"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintHorizontal_bias="0.882"
          android:layout_marginTop="8dp"
          app:layout_constraintTop_toBottomOf="@+id/l_width"
          app:layout_constraintVertical_bias="0.162"
          android:id="@+id/frameLayout2"&gt;
  
  
          &lt;include
              android:id="@+id/other"
              android:layout_width="300dp"
              android:layout_height="200dp"
              android:visibility="visible"
              layout="@layout/sample1" /&gt;
  
      &lt;/FrameLayout&gt;
  
  
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>values given in xml so its showing properly:
  <a href="https://i.stack.imgur.com/DQNj5.png" rel="nofollow noreferrer">Result using XML</a></p>
  
  <p>Values in given java code so its showing very smallbox
  <a href="https://i.stack.imgur.com/fQiTR.png" rel="nofollow noreferrer">Result using Java</a></p>
  
  <p>How can I change the framelayout width and height programatically?</p>
  
  <p>Please help me.</p>