0

Screen shot

This is an alert dialog. I don't want to show the grey coloured portion (at top), which is background of the parent layout; instead that portion should be clear and the previous activity should be shown there as being shown outside the dialog. Also the border of the circular image view be tight with the image. How do I do that? Thanks in advance.

Mylayout.xml

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#727272">

<RelativeLayout
    android:id="@+id/card_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card_save"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:foreground="?android:attr/selectableItemBackground"
        card_view:cardBackgroundColor="#ffffff"
        card_view:cardCornerRadius="4dp"
        card_view:cardElevation="0dp"
        card_view:cardUseCompatPadding="false">

        <RelativeLayout
            android:id="@+id/rl_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp">


            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_date"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="60dp">
                <TextView
                    android:id="@+id/tv_date"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/textView_DoB"
                    android:paddingTop="10dp"
                    android:paddingStart="10dp"
                    android:paddingEnd="10dp"
                    android:hint="@string/dd_mm_yyyy"
                    android:textColor="@android:color/black"
                    android:textAlignment="viewStart"
                    android:textSize="25sp"
                    android:background="@drawable/border_date"/>

            </android.support.design.widget.TextInputLayout>
            <ImageButton
                android:id="@+id/ib_DoB_in_dialog"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@id/til_date"
                android:layout_marginTop="63dp"
                android:layout_marginEnd="5dp"
                android:background="@mipmap/calendar"
                android:contentDescription="@string/calendar_image" />

            <TextView
                android:id="@+id/textView_DoB_weekday"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@id/til_date"
                android:layout_marginTop="20dp"
                android:layout_marginStart="10dp"
                android:layout_marginEnd="10dp"
                android:textColor="@android:color/black"
                android:textAlignment="viewStart"
                android:textSize="20sp"
                />

            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/til_date"
                android:layout_marginTop="10dp">
                <android.support.design.widget.TextInputEditText
                    android:id="@+id/et_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/name"
                    android:inputType="textCapWords" />
            </android.support.design.widget.TextInputLayout>


            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_category"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/til_name"
                android:layout_marginTop="10dp">
                <Spinner
                    android:id="@+id/sp_category"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:entries="@array/Category">
                </Spinner>
            </android.support.design.widget.TextInputLayout>




            <android.support.design.widget.TextInputLayout
                android:id="@+id/til_mobile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/til_category"
                android:layout_marginTop="10dp">
                <android.support.design.widget.TextInputEditText
                    android:id="@+id/et_mobile"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="@string/mobile_number_optional"
                    android:inputType="number"
                    android:maxLength="13"/>
            </android.support.design.widget.TextInputLayout>

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/til_mobile"
                android:layout_marginTop="10dp">
                <TableRow>
                    <Button
                        android:id="@+id/btn_discard"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_column="0"
                        android:layout_weight="1"
                        android:text="@string/discard" />

                    <Button
                        android:id="@+id/btn_save_data"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_column="1"
                        android:layout_weight="1"
                        android:text="@string/save" />
                </TableRow>
            </TableLayout>


        </RelativeLayout>

    </android.support.v7.widget.CardView>

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/civ_profile_image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerHorizontal="true"
        android:src="@mipmap/ic_person_image"
        card_view:civ_border_width="2dp"
        card_view:civ_border_color="#ffffff"/>

</RelativeLayout>

Cjsparrow
  • 59
  • 2
  • 2
  • 9

1 Answers1

0

add this on your parent xml

android:background="@android:color/transparent" 

and add this to your code so the whole alert dialog become transparent

alertDialog.getWindow().setDimAmount(0);
Boukharist
  • 1,219
  • 11
  • 19
  • Yes, but then the whole dialog background becomes white and I don't want that. I want the half portion of the image be above the white portion as now except the grey portion. – Cjsparrow Nov 08 '17 at 16:21
  • i updated my answer , your alert dialog default color is white – Boukharist Nov 08 '17 at 16:24
  • 1
    the problem is with your alert dialog that is not transparent see here for more https://stackoverflow.com/questions/25174165/transparent-alertdialog-has-black-background – Boukharist Nov 08 '17 at 16:26
  • Thanks @Boukharist. alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); did the trick. Now can you please tell me how to make the border of circular image view tight to the image. – Cjsparrow Nov 08 '17 at 16:56
  • Also a warning is shown-"Method invocation 'setBackgroundDrawable' may produce 'java.lang.NullPointerException'." How to fix the warning? – Cjsparrow Nov 08 '17 at 17:08