title: Android AlertDialog with rounded corners
body: <p>I have been trying to make my Alert Dialog with rounded corners but somehow I am not able to. I have tried and I failed. I tried to follow this blog <a href="http://blog.stylingandroid.com/archives/271" rel="noreferrer">http://blog.stylingandroid.com/archives/271</a> and made my styles based on that.</p>
  
  <p><strong>Btw, to add to my question now. Some of my new finding. The code in the above link just works fine on 2.3.3 (GB) but does not work at all in ICS . Some change made the code to break.</strong></p>
  
  <p><strong>I want to avoid creating 9 patch images and thus I am using shapes. 9 patch image is the last thing that I will try.I know that android alert dialog style is using 9 patch image. I already looked that up before throwing this question.</strong></p>
  
  <p><strong>/res/values/themes.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
      &lt;style name="MyTheme" parent="@android:style/Theme.Dialog"&gt;
          &lt;item name="android:alertDialogStyle"&gt;@style/dialog&lt;/item&gt;
      &lt;/style&gt;
  
  
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>/res/values/styles.xml</strong></p>
  
  <pre><code>&lt;resources xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;style name="AppTheme" parent="android:Theme.Light" /&gt;
  
      &lt;style name="myImageView"&gt;
  
          &lt;!-- 3dp so the background border to be visible --&gt;
          &lt;item name="android:padding"&gt;3dp&lt;/item&gt;
          &lt;item name="android:background"&gt;@drawable/image_drawable&lt;/item&gt;
          &lt;item name="android:scaleType"&gt;fitCenter&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="dialog"&gt;
          &lt;item name="android:fullDark"&gt;@drawable/dialog_body&lt;/item&gt;
          &lt;item name="android:topDark"&gt;@drawable/dialog_title&lt;/item&gt;
          &lt;item name="android:centerDark"&gt;@drawable/dialog_body&lt;/item&gt;
          &lt;item name="android:bottomDark"&gt;@drawable/dialog_footer&lt;/item&gt;
          &lt;item name="android:fullBright"&gt;@drawable/dialog_body&lt;/item&gt;
          &lt;item name="android:centerBright"&gt;@drawable/dialog_body&lt;/item&gt;
          &lt;item name="android:topBright"&gt;@drawable/dialog_title&lt;/item&gt;
          &lt;item name="android:bottomBright"&gt;@drawable/dialog_footer&lt;/item&gt;
          &lt;item name="android:bottomMedium"&gt;@drawable/dialog_footer&lt;/item&gt;
          &lt;item name="android:centerMedium"&gt;@drawable/dialog_body&lt;/item&gt;
      &lt;/style&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>/res/drawable/dialog_title.xml</strong></p>
  
  
  
  <pre><code>&lt;inset xmlns:android="http://schemas.android.com/apk/res/android"
      android:insetBottom="-1dp"&gt;
      &lt;shape android:shape="rectangle"&gt;
          &lt;solid android:color="#FFFFFF" /&gt;
          &lt;corners android:topLeftRadius="5dp" android:topRightRadius="5dp" /&gt;
          &lt;stroke android:color="#FFFFFF" android:width="1dp" /&gt;
      &lt;/shape&gt;
  &lt;/inset&gt;
  </code></pre>
  
  <p><strong>/res/drawable/dialog_body.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle"&gt;
      &lt;gradient android:startColor="#FFFFFFFF" android:endColor="#FFFFFFFF"
          android:angle="270" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p><strong>/res/drawable/dialog_footer.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle" &gt;
  
      &lt;solid android:color="#FFFFFF" /&gt;
  
      &lt;corners
          android:bottomLeftRadius="5dp"
          android:bottomRightRadius="5dp" /&gt;
  
      &lt;stroke
          android:width="1dp"
          android:color="#FFFFFF" /&gt;
  
  &lt;/shape&gt;
  </code></pre>
  
  <p><strong>res/layout/dialog_layout.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="45dp"
          android:text="Large Text"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/textView1"
          android:layout_marginTop="90dp"
          android:layout_toLeftOf="@+id/textView1"
          android:background="@drawable/button_selector"
          android:text="Ok"
          android:textColor="@android:color/white"
          android:textStyle="bold" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_alignTop="@+id/button1"
          android:layout_marginRight="48dp"
          android:background="@drawable/button_selector"
          android:text="More"
          android:textColor="@android:color/white"
          android:textStyle="bold" /&gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/button1"
          android:layout_marginTop="41dp"
          android:orientation="vertical" &gt;
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>My code  for AlertDialog:</strong></p>
  
  <pre><code>public static void createYesNoDialog(final Context context, String positivebuttonname,
              String negativebuttonname, String message, int messagedrawable, String headermessage,
              final DialogResponse dr) {
          final DialogResponse dialogResponse = dr;
          ContextThemeWrapper ctw = new ContextThemeWrapper(context,
                  com.gp4ever.worldlogo.quiz.R.style.MyTheme);
  
          AlertDialog.Builder builder = new AlertDialog.Builder(ctw);
          LayoutInflater inflater = (LayoutInflater)context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View layout = inflater.inflate(com.gp4ever.worldlogo.quiz.R.layout.dialog_layout, null);
          TextView text = (TextView)layout.findViewById(com.gp4ever.worldlogo.quiz.R.id.textView1);
          Button buttonOk = (Button)layout.findViewById(com.gp4ever.worldlogo.quiz.R.id.button1);
          Button buttonMore = (Button)layout.findViewById(com.gp4ever.worldlogo.quiz.R.id.button2);
          text.setText(message);
          if (messagedrawable &gt; 0) {
              text.setCompoundDrawablesWithIntrinsicBounds(messagedrawable, 0, 0, 0);
          } else if (messagedrawable == 0)
              text.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
          builder.setView(layout);
          builder.setCancelable(false);
          builder.setTitle(headermessage);
          builder.setIcon(android.R.drawable.ic_dialog_alert);
          final AlertDialog dialog = builder.create();
  
          buttonOk.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  dialog.cancel();
              }
          });
          buttonMore.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  dialog.cancel();
              }
          });
  </code></pre>
  
  <p>}</p>
  
  <p><strong>My current output:</strong></p>
  
  <p>I do not get any rounded corners. I can see that it is different from the usual style. Even though I change radius on my drawable, the corners does not reflect to those changes.</p>
  
  <p><img src="https://i.stack.imgur.com/PwquZ.png" alt="enter image description here"></p>