title: Android align close button to top right corner of the dialog box?
body: <p>i am working on a custom dialog box and i want to place my close button to the top right corner of the dialog so that the close image would be partially in the dialog box and partially outside....
  (<a href="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSSfhWv1zPYhmCFVsO70qLY-CqGIKplU3TAVL6zdHaxvLZMsqYnwg" rel="noreferrer">https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSSfhWv1zPYhmCFVsO70qLY-CqGIKplU3TAVL6zdHaxvLZMsqYnwg</a>)</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:background="@drawable/someborder"
  android:orientation="horizontal"
  android:baselineAligned="false"&gt;
  
   &lt;LinearLayout
           android:layout_width="0dp"
           android:layout_height="fill_parent"
           android:gravity="top|left"
           android:orientation="vertical" 
           android:layout_weight="0.65"&gt;
  
      &lt;LinearLayout 
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical"&gt; 
        &lt;LinearLayout   
          android:layout_width="fill_parent"
          android:layout_height="0dp"
          android:orientation="horizontal"
          android:layout_weight="0.82" &gt;  
           &lt;ScrollView 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scrollbars="vertical" 
      android:paddingBottom="10dp"
              android:paddingLeft="8dp"
              android:paddingRight="5dp"
              android:paddingTop="10dp"&gt;
  
           &lt;TableLayout
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_gravity="left" &gt;
  
           &lt;TableRow
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" &gt;
  
               &lt;TextView
                   android:layout_width="0dp"
                   android:layout_height="wrap_content"
                   android:layout_weight="0.30"
                   android:gravity="center"
                   android:shadowColor="@color/color"
                   android:shadowDx="1"
                   android:shadowDy="1"
                   android:shadowRadius="1"
                   android:paddingLeft="1.2dp" /&gt;
  
               &lt;TextView
                   android:layout_width="0dp"
                   android:layout_height="wrap_content"
                   android:layout_weight="0.20"
                   android:gravity="center|center_vertical"
                   android:shadowColor="@color/color"
                   android:shadowDx="1"
                   android:shadowDy="1"
                   android:shadowRadius="1"/&gt;
  
               &lt;TextView
                   android:layout_width="0dp"
                   android:layout_height="wrap_content"
                   android:layout_weight="0.25"
                   android:gravity="center_vertical|center"
                   android:shadowColor="@color/color"
                   android:shadowDx="1"
                   android:shadowDy="1"
                   android:shadowRadius="1" /&gt;
  
               &lt;TextView
                   android:layout_width="0dp"
                   android:layout_height="wrap_content"
                   android:layout_weight="0.25"
                   android:gravity="center_vertical|center"
                   android:shadowColor="@color/color"
                   android:shadowDx="1"
                   android:shadowDy="1"
                   android:shadowRadius="1" /&gt;
           &lt;/TableRow&gt; 
      &lt;/TableLayout&gt;  
    &lt;/ScrollView&gt; 
   &lt;/LinearLayout&gt; 
   &lt;ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/horizontal_line" /&gt;
   &lt;LinearLayout 
         android:layout_width="wrap_content"
         android:layout_height="0dp"
         android:orientation="vertical"
         android:gravity="top|left"
         android:layout_weight=".15"&gt;
  
       &lt;LinearLayout 
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:orientation="horizontal"
           android:gravity="center"
           android:paddingLeft="12dp"
           android:paddingBottom="5dp"&gt;
  
           &lt;CheckBox
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:gravity="center"
               android:paddingLeft="10dp"
               android:textSize="12sp"/&gt;
  
      &lt;/LinearLayout&gt;  
     &lt;/LinearLayout&gt; 
     &lt;/LinearLayout&gt;         
     &lt;/LinearLayout&gt;
  
   &lt;ImageView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:paddingBottom="2dp"
       android:paddingTop="1.75dp"
       android:src="@drawable/vertical_line" /&gt;
  
   &lt;LinearLayout 
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:gravity="top|right"
      android:layout_weight=".38"&gt;
  
   &lt;LinearLayout 
      android:layout_width="fill_parent"
      android:layout_height="0dp"
          android:layout_weight=".60"
          android:orientation="horizontal"
          android:gravity="top|right"&gt;
  
       &lt;ImageView
           android:id="@+id/id"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:gravity="center"/&gt;
  
       // Close button         
        &lt;ImageView 
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="top|right"/&gt;
  // Close Button
  
       &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
           android:id="@+id/linear_layout"
           android:layout_width="fill_parent"
           android:layout_height="0dp"
           android:layout_weight=".40"
           android:orientation="vertical"
           android:paddingBottom="8dp" &gt;
  
         &lt;LinearLayout
           android:layout_width="wrap_content"
           android:layout_height="0dp"
           android:layout_weight=".40"
           android:layout_gravity="center"
           android:orientation="vertical" &gt;
  
           &lt;RadioButton
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:gravity="center"
               android:layout_weight="0.33" 
               android:textAlignment="center"/&gt;
  
           &lt;RadioButton
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:gravity="center"
               android:layout_weight="0.33" 
               android:textAlignment="center"/&gt;
  
           &lt;RadioButton
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:gravity="center"
               android:layout_weight="0.33" 
               android:textAlignment="center"/&gt;
  
           &lt;/LinearLayout&gt;
  
       &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Like this image and its red close button.
  Thanx everybody in advance..</p>