Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create dialog with cross button layout in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 981
    Comment on it

     In the below example I have created a dialog button layout. Here I have created a main.activity layout, In main.xml layout first I have created  Relative layout and added all layout in this Main Relative layout then I have  created a Relative layout for body of paticular size of dilog box and I have also added TextView, ImageView, ImageButton. In below second step I have creted rounded.xml layout in drawable folder here I have added dialog shape and color properties. You can see below program it will clearly describe you to create dialog with cross button layout.

    
    Step(1)-main_activity.xml layout-
    
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="300dp"
        android:layout_height="wrap_content">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:background="@drawable/rounded_border">
    
            <!--Main Body of your custom dialog-->
    
            <RelativeLayout
                android:layout_width="match_parent"
                android:id="@+id/editbusineslayout"
                android:layout_height="50dp">
    
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:gravity="center"
                    android:text="@string/edit_business"
                    android:textColor="@color/colorPrimary"
                    android:textSize="@dimen/text_large"
                    android:textStyle="bold"/>
            </RelativeLayout>
    
            <ImageView
                android:id="@+id/lineimageview"
                android:layout_below="@+id/editbusineslayout"
                android:layout_width="match_parent"
                android:layout_height="0.8dp"
                android:src="@color/colorPrimary"/>
            <RelativeLayout
                android:layout_below="@+id/lineimageview"
                android:layout_width="match_parent"
                android:id="@+id/editOfferslayout"
                android:layout_height="50dp">
    
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:gravity="center"
                    android:text="@string/edit_offers"
                    android:textColor="@color/colorPrimary"
                    android:textSize="@dimen/text_large"
                    android:textStyle="bold"/>
            </RelativeLayout>
        </RelativeLayout>
    
        <LinearLayout
            android:id="@+id/llTop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
    
            android:layout_alignParentTop="true"
            android:orientation="vertical">
    
            <ImageButton
                android:id="@+id/btnCancel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/btnBookK"
                android:background="@null"
                android:src="@mipmap/ic_close_circle_outline_black_36dp" />
    
        </LinearLayout>
    
    </RelativeLayout>
    
    
    Step(2)-Create a rounded.xml layout in drawable folder 
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item>
            <shape android:shape="rectangle" >
                <solid android:color="@color/font_color" />
                <corners android:radius="12dip" />
                <stroke
                    android:width="1dip"
                    android:color="@color/colorPrimaryDark" />
            </shape>
        </item>
    </layer-list>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: