Satheesh
Satheesh

Reputation: 1730

Remove alert dialog border android

enter image description here

In my application set one view in alert dialog. My problem is when i show this alert dialog remove the layer of the alert dialog and show only the background theme or view this alert dialog with rounded rectangle only.please any one help me thanks.I add my theme and layout files.

In my Activity

AlertDialog.Builder alertViewTaskDescription = new AlertDialog.Builder(
                  getActivity(), R.style.Theme_CustomDialog);
            LayoutInflater inflaterViewTaskDescription = (LayoutInflater) getActivity()
                  .getSystemService(getActivity().LAYOUT_INFLATER_SERVICE);
            viewTaskWithDescription = (View) inflaterViewTaskDescription
                  .inflate(R.layout.viewtaskwithdescriptionlayout, null,
                        false);

            final EditText edittextTask = (EditText) viewTaskWithDescription
                  .findViewById(R.id.taskidDaytoDayView);
            TextView textviewDescription = (TextView) viewTaskWithDescription
                  .findViewById(R.id.descriptionidDaytoDayView);
            edittextTask.setText(taskName);
            edittextTask.setSelection(edittextTask.getText().length());
            textviewDescription.setText("ADD DESCRIPTION");
            alertViewTaskDescription.setView(viewTaskWithDescription);

My layout file

 <?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" >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:text="Task with Description"
        android:textSize="20sp"
        android:textStyle="bold"
        android:gravity="center_horizontal"
        android:scaleType="center">
    </TextView>
    <TextView 
        android:id="@+id/textviewidtaskname"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="15dp"
        android:textStyle="bold"
        android:text="Task Name:"/>
    <EditText
        android:id="@+id/taskidDaytoDayView"
        android:layout_width="fill_parent"
        android:background="@drawable/edittextselector"
        android:layout_height="wrap_content" 
        android:singleLine="false"
        android:lines="2"
        android:maxLines="10"
        android:scrollbars="vertical"
        >
    </EditText>
    </LinearLayout>
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">


    <TextView
        android:layout_marginTop="10dp"
        android:drawableRight="@drawable/down"
        android:textSize="17.5dp"
        android:id="@+id/descriptionidDaytoDayView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Add More Details"
        android:clickable="true"

        >
    </TextView>
    </LinearLayout>



</LinearLayout>

My Theme:

     <style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
        <item name="android:windowBackground">@drawable/shapedialogtheme</item>
        <!-- <item name="android:windowNoTitle">true</item> -->
    </style>



    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"  >

    <solid android:color="#565656" />


    <stroke
        android:width="5dp"
        android:color="#ffff8080" />

    <corners android:radius="30dp" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />
    <size 
        android:width="150dp"
        android:height="150dp"/>

</shape>

Upvotes: 2

Views: 2019

Answers (1)

amalBit
amalBit

Reputation: 12191

Instead of using an alertbuilder to create a dialog.

You can use plain dialog.

Dialog d =new dialog(getActivity(), R.style.Theme_CustomDialog);

d.setContentView(r.x.x);// design a layout in xml and add here.

Upvotes: 1

Related Questions