Подтвердить что ты не робот

Как изменить заголовок разделителя заголовка диалогового окна

Я хотел создать стиль или изменить цвет разделителя заголовка в диалоговом окне предупреждения. Я ищу об этом вопросе, и я думаю, что многие люди ищут это. Но я все еще не могу найти правильное решение. Я хочу изменить это. Blue header divider

4b9b3361

Ответ 1

Вы можете изменить цвет заголовка AlertDialog очень простым взломом:

public static void brandAlertDialog(AlertDialog dialog) {
    try {
        Resources resources = dialog.getContext().getResources();
        int color = resources.getColor(...); // your color here

        int alertTitleId = resources.getIdentifier("alertTitle", "id", "android");
        TextView alertTitle = (TextView) dialog.getWindow().getDecorView().findViewById(alertTitleId);
        alertTitle.setTextColor(color); // change title text color

        int titleDividerId = resources.getIdentifier("titleDivider", "id", "android");
        View titleDivider = dialog.getWindow().getDecorView().findViewById(titleDividerId);
        titleDivider.setBackgroundColor(color); // change divider color
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

Ответ 2

Цвет разделителя: -

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.dialog)
   .setIcon(R.drawable.ic)
   .setMessage(R.string.dialog_msg);
Dialog d = builder.show();
int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = d.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(R.color.my_color));

Ответ 3

Судя по источнику, кажется, что этот цвет жестко запрограммирован. Я считаю, что это ошибка, она должна быть изменчивой imho.

Существует простой способ: используйте setStyle(DialogFragment.STYLE_NO_TITLE, R.style.myStyle); и напишите простой линейный макет, где первым элементом будет ваш заголовок.

Ответ 4

QustomDialogBuilder qustomDialogBuilder = new QustomDialogBuilder(context).
        setTitle("Set IP Address").
        setTitleColor("#FF00FF").
        setDividerColor("#FF00FF").
        setMessage("You are now entering the 10th dimension.").
qustomDialogBuilder.show();