title: Android: How to change dynamically size of child views to fit parent view size?
body: <p>I have a LinearLayout with 3 or 4 views (Buttons and ImageButtons) inside, and I want that all of them have the same size to fit entirely the layout, like shown in the picture below <img src="https://i.stack.imgur.com/P1Lx7.png" alt="example">
   The same thing must be done either in horizontal and in vertical.</p>
  
  <p>the xml of the LinearLayout is this:</p>
  
  <pre><code> &lt;LinearLayout
      android:id="@+id/discover_right_action_bar"
      android:layout_width="64dp"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      android:layout_below="@id/top_navi_bar"
      android:background="@color/smart_dark_grey"
      android:gravity="center"
      android:orientation="vertical"
      android:paddingBottom="5dp"
      android:paddingTop="5dp" &gt;
  
      &lt;ImageButton
          android:id="@+id/home_ib_friend"
          android:layout_width="60dp"
          android:layout_height="60dp"
          android:layout_marginLeft="5dp"
          android:layout_marginRight="5dp"
          android:saveEnabled="false"
          android:scaleType="center"
          android:src="@drawable/ic_action_select_all" /&gt;
  
      &lt;ImageButton
          android:id="@+id/home_ib_camera"
          android:layout_width="60dp"
          android:layout_height="60dp"
          android:layout_marginLeft="5dp"
          android:layout_marginRight="5dp"
          android:saveEnabled="false"
          android:scaleType="center"
          android:src="@drawable/ic_action_camera" /&gt;
  
      &lt;ImageButton
          android:id="@+id/ib_prof_mon_meetings"
          android:layout_width="60dp"
          android:layout_height="60dp"
          android:layout_marginLeft="5dp"
          android:layout_marginRight="5dp"
          android:saveEnabled="false"
          android:scaleType="centerInside"
          android:src="@drawable/clock" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Now I can only set or the size manually in dp, or set it to wrap_content, but than there would be space at the beginning and at the end of the layout.</p>
  
  <p>I've tried something with the layout_weight attribute but I don't know well how to use it.</p>
  
  <p>I've tried also with getting the real size of the layout (via ViewTreeObserver) and set the size to the internal children but it doesn't work because I couldn't get the real dimension of the layout.</p>