[안드로이드 스튜디오] Alertdialog 창의 색이 어둡습니다..

조회수 3440회

현재 상황은 이렇습니다

이미지

자바 코드는

Sagin.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    View dlgView = View.inflate(Activity2.this,ac2_sub,null);
                    AlertDialog.Builder dlg = new AlertDialog.Builder(Activity2.this);
                    ImageView Sagin = (ImageView)dlgView.findViewById(R.id.Sagin);
                    Sagin.setImageResource(foodID[pos]);
                    dlg.setTitle(foodName[pos]);
                    dlg.setIcon(R.drawable.food_bag_small);
                    dlg.setView(dlgView);
                    dlg.setNegativeButton("취소", null);
                    dlg.setPositiveButton("선택", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(Activity2.this,Activity3.class);
                            startActivity(intent);
                        }
                    });
                    dlg.show();
                }
            });

이렇구요

ac2_sub.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="@drawable/custom_background"
    >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/Sagin"/>


</LinearLayout>

custom_background 입니다.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape>
        <solid android:color="#ffffff"/>
    </shape>
    </item>
</layer-list>

대화상자의 모든 면을 하얀색으로 하고싶습니다

현재 의심가는 바로는 모든 액티비티의 액션바를 없앴고

이로 인해 위 사진처럼 배경이 어두워지는 액티비티들을

전부 background="#ffffff" 처리 해줬습니다

저 대화상자문도 어떻게 처리를 해줘야할것같은데

갈피를 못잡겠습니다..

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

  • AppTheme에 android:alertDialogTheme 속성이 들어가있어 나타나는 현상으로 보입니다.

    이것을 주석처리하면 흰색배경으로 나타날 것으로 보이고요. 아니라면 AlertDialog를 커스터마이징하는 방법이 있습니다.

    //dlg.show();
    AlertDialog dialog = dlg.create();
    //dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    //or
    dialog.getWindow().setBackgroundDrawable(android.R.color.white);
    dialog.show();
    

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)