title: why android:layout_gravity="right" not working here in android xml
body: <p>my xml code for list view's row 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:layout_width="match_parent"
      android:layout_height="match_parent"
      android:baselineAligned="false"
      android:orientation="horizontal" &gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="5"
          android:orientation="vertical" &gt;
  
          &lt;TextView
              android:id="@+id/tv_name"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="10dp" /&gt;
  
          &lt;TextView
              android:id="@+id/tv_time"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="10dp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_weight="2"
          android:gravity="center" &gt;
  
          &lt;ImageView
              android:id="@+id/iv_image"
              android:layout_width="50dp"
              android:layout_height="40dp"
              android:background="@drawable/app_icon_17"
              android:contentDescription="@string/empty" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_gravity="right"
          android:layout_weight="2"
          android:gravity="center" &gt;
  
          &lt;Button
              android:id="@+id/btn_delete"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:background="@drawable/btn_delete_new"
              android:focusable="false" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I want the last button with id btn_delete to stay right aligned. And its showing as I wanted in "graphical layout" while designing. But when I run it, on emulator it's not working. </p>
  
  <p>See the output :</p>
  
  <p><img src="https://i.stack.imgur.com/kcFIz.png" alt="enter image description here"></p>
  
  <p>So why the delete button not getting right aligned?</p>