title: How to center align 2 views?
body: <p><strong>layout.xml</strong></p>
  <pre><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:orientation=&quot;vertical&quot;&gt;
      &lt;RelativeLayout
          android:id=&quot;@+id/viewPost&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;40dp&quot;
          android:layout_marginTop=&quot;14dp&quot;
          android:background=&quot;@color/bg_blue&quot;
          android:gravity=&quot;center&quot; &gt;
  
          &lt;ImageView
              android:id=&quot;@+id/ic_viewPost&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:src=&quot;@drawable/ic_view&quot; /&gt;
  
          &lt;TextView
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginLeft=&quot;10dp&quot;
              android:layout_toRightOf=&quot;@id/ic_viewPost&quot;
              android:gravity=&quot;center&quot;
              android:text=&quot;View post&quot;
              android:textColor=&quot;@color/white&quot;
              android:textSize=&quot;14sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
      &lt;/RelativeLayout&gt;
  
      &lt;RelativeLayout
          android:id=&quot;@+id/socialShare&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;40dp&quot;
          android:layout_marginTop=&quot;14dp&quot;
          android:background=&quot;@color/bg_light_grey&quot;
          android:gravity=&quot;center&quot; &gt;
  
          &lt;ImageView
              android:id=&quot;@+id/ic_socialShare&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:src=&quot;@drawable/ic_share_post&quot; /&gt;
  
          &lt;TextView
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginLeft=&quot;10dp&quot;
              android:layout_toRightOf=&quot;@id/ic_socialShare&quot;
              android:gravity=&quot;center&quot;
              android:text=&quot;Share with others&quot;
              android:textColor=&quot;@color/text_dark_grey&quot;
              android:textSize=&quot;14sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p><strong>In graphical layout:</strong></p>
  <p><img src="https://i.stack.imgur.com/BDVmd.png" alt="enter image description here" /></p>
  <p><strong>On actual device:</strong></p>
  <p><img src="https://i.stack.imgur.com/xwE7v.png" alt="enter image description here" /></p>
  <p>In the graphical layout it looks the way I wanted, but on actual device its completely different.</p>
  <p>In the 1st Relative Layout the ImageView and TextView are not at all aligned.</p>
  <p>In the 2nd Relative Layout it looks like the TextView is bottom aligned to the ImageView.</p>
  <p>Thank You.</p>