title: dynamic layout for 4 icons that must stay in a rational distance from each other in android
body: <p>i have this layout for bottom bar of my app:</p>
  
  <p><img src="https://i.stack.imgur.com/WMLRj.jpg" alt="enter image description here"></p>
  
  <p>but i want to make it like this:</p>
  
  <p><img src="https://i.stack.imgur.com/f1auC.jpg" alt="enter image description here"></p>
  
  <p>actually i can but i want that , this layout works in every screen size. in fact, left icon sticks to left, right icon sticks to right, two center icon stay at center but all of them stay with a nice distance to each other. i don't use absolute values and i want this icons dynamically change his distance from others. my problem is how to layout them to achieve my goal. </p>
  
  <p>this is my xml for this section:</p>
  
  <pre><code> &lt;LinearLayout
              android:id="@id/bar_l2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_alignParentLeft="true"
              android:layout_alignParentRight="true"
              android:gravity="center_horizontal" &gt;
  
              &lt;RelativeLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="@drawable/bottom_bar" &gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_alignParentLeft="true"
                      android:layout_alignParentRight="true"
                      android:gravity="center_horizontal"
                      android:orientation="horizontal" &gt;
  
                      &lt;LinearLayout
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content" &gt;
  
                          &lt;ImageView
                              android:id="@+id/imageView1"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:src="@drawable/bar1" /&gt;
  
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content" &gt;
  
                          &lt;ImageView
                              android:id="@+id/imageView2"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:src="@drawable/bar2" /&gt;
  
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content" &gt;
  
                          &lt;ImageView
                              android:id="@+id/imageView3"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:src="@drawable/bar3" /&gt;
  
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="match_parent" &gt;
  
                          &lt;ImageView
                              android:id="@+id/imageView4"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_gravity="center_horizontal"
                              android:src="@drawable/bar4" /&gt;
  
                      &lt;/LinearLayout&gt;
  
                  &lt;/LinearLayout&gt;
  
              &lt;/RelativeLayout&gt;
  
          &lt;/LinearLayout&gt;
  </code></pre>