final Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_select_action_new);
dialog.show(); requestWindowFeature method is need to be set before setContentView And in <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/text_view_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Select an Action"
android:textStyle="bold"
android:padding="16dp"/>
<Button
android:id="@+id/button_action1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Action 1"/>
<Button
android:id="@+id/button_action2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Action 2"/>
</LinearLayout> file we have freedom to make any modifications, just like this: <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0f7fa"
android:minWidth="350dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#97c7dc"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/add_event_title"
android:textColor="#ffffff"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f0f7fa"
android:orientation="vertical"
android:padding="10dp" >
<Button
android:id="@+id/dialog_select_fun_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_add_fun"
android:drawableLeft="@drawable/fun_icon"
android:drawablePadding="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/add_event_fun_btn"
android:textColor="#ffffff" />
<Button
android:id="@+id/dialog_select_ill_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/btn_add_fun"
android:drawableLeft="@drawable/baby_health_icon"
android:drawablePadding="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/add_event_fun_ill"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout> Final result is:
ps: The big plus from that is on android 2.x devices dialog looks like android 4.x version.