Bhavit S. Sengar
Bhavit S. Sengar

Reputation: 8924

Customized Dialog in Android

I want to make the exact dialog box as given in this picture : Customized dialog box

How do I achieve the same look and feel, can anyone suggest please.

Upvotes: 1

Views: 82

Answers (4)

Deniz
Deniz

Reputation: 12530

Can you try this

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/parent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="15dip"
        android:background="@drawable/popup_bg"
        android:orientation="vertical" >
    //add list items here

    </LinearLayout>

    <ImageView
        android:id="@+id/close_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:clickable="true"
        android:cropToPadding="true"
        android:onClick="dismissPopUp"
        android:src="@drawable/icon_close_btn" />

</RelativeLayout>

Upvotes: 0

It's just a straight forward xml layout, the only trick is to have layout background a transluent png with rounded corners, and disable border on your dialog

Upvotes: 0

Vaibhav Agarwal
Vaibhav Agarwal

Reputation: 4499

Use separate xml file for your dialog look. on the button click of your activity call this dialog

here is link to tutorial related to dialog implementation in android

Tutorial 1

Tutorial 2

Upvotes: 0

Joe Birch
Joe Birch

Reputation: 371

It's not too tricky :) You need to create a custom dialog. You'd begin by extending AlertDialog and overriding the onCreate method.

Within this custom dialog class you can use setContentView to assign a specific layout file to that dialog class, in which you can manipulate the contents however you like.

Upvotes: 1

Related Questions