i want to build a customized dialog just like the one shown in image:
i have created two layout one for custom title & other containing two edit text view along with two buttons.Here are xml’s
custom_title
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/popup_title"
android:gravity="center_vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addView"
android:textColor="@color/black"
android:paddingLeft="15dp"/>
</LinearLayout>
custom_dialog.xml
<?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:orientation="vertical"
android:background="@color/white" >
<EditText
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/title"
android:layout_weight="1" />
<EditText
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/details"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_add"
android:layout_weight="1"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_cancel"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
You just have to inflate the Dialog with your xml file.
I’ll just give you a sample code, then you can easily follow
Now create a function as :-
Finally make sure you have the style as :-
That’s it …. you are done… just call this function where ever you want to show the custom dialog….
Hope the explanation was useful….