AlertDialog 에서 취소 확인 버튼이 안보일 때

By | 2021년 11월 7일
Table of Contents

AlertDialog 에서 취소 확인 버튼이 안보일 때

AlertDialog 에서 취소 확인 버튼이 안보일 때가 있다.

하지만 실제로는 없는 것이 아니라 글자색과 바탕색이 동일해서 안보이는 경우이다.

커스템 테마생성

theme.xml 파일에 아래 내용을 추가해 준다.

    <style name="AlertDialogTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert">
        <item name="colorPrimary">#0000FF</item>
    </style>

소스를 아래와 같이 수정해 준다.

import android.app.AlertDialog;
......
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AlertDialogTheme));
......
AlertDialog alertDialog = builder.create();
        alertDialog.show();

답글 남기기