2

在此处输入图像描述

在我的应用程序中,在警报对话框中设置一个视图。我的问题是当我显示此警报对话框时,删除警报对话框的图层并仅显示背景主题或仅查看带有圆角矩形的警报对话框。请任何人帮助我,谢谢。我添加了我的主题和布局文件。

在我的活动中

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);

我的布局文件

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

我的主题:

     <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>
4

1 回答 1

1

而不是使用 alertbuilder 创建对话框。

您可以使用普通对话框。

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

d.setContentView(r.x.x);// design a layout in xml and add here.
于 2013-07-13T07:58:19.990 回答