android:警告对话框背景色在正按钮后面不改变

rpppsulh  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(285)

我有麻烦的自定义aletdialog与edittext在,当我设置背景色对话框的颜色在后面不改变,除了部分,包括积极和消极的按钮。

对话框的布局文件:

<?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="@color/colorNoteBook"
    android:padding="16dp">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="INSTRUCTIONS:" />

    <com.example.recical.ui.MyLab.LinedEditText
        android:id="@+id/editText_instructions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/textView2"
        android:layout_alignParentStart="true"
        android:layout_marginTop="20dp"
        android:background="@color/colorNoteBook"
        android:ems="10"
        android:gravity="start|top"
        android:inputType="textMultiLine"
        android:minLines="8" />
</RelativeLayout>

java类

public class CustomDialog extends AppCompatDialogFragment {

    private EditText et_in_dialog;
    private CustomDialogListener listener;

    @NonNull
    @Override**strong text**
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());

        LayoutInflater inflater=getActivity().getLayoutInflater();
        View view=inflater.inflate(R.layout.layout_dialog,null);
        builder.setView(view)
//                .setTitle("Instructions")
               .setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                    }
                })
               .setPositiveButton("Save", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                         String instructions=et_in_dialog.getText().toString();
                         listener.applyText(instructions);
                    }
                });
        et_in_dialog=view.findViewById(R.id.editText_instructions);
        return builder.create();

    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);

        try {
            listener=(CustomDialogListener)context;
        } catch (ClassCastException e) {
            throw new ClassCastException(context.toString()+"must implement CustomDialogListener");
        }
    }

    public interface CustomDialogListener{            // this the interface tabbed activity will call
        void applyText(String instructions);
    }
}

我该如何设计ok和custom按钮后面的区域?我想把它完全变成黄色

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题