2010-12-08 4 views

ответ

1

You есть некоторые подсказки на anddev.org. Основная идея - расширить тему по умолчанию и использовать ее в своей деятельности. В частности, вам нужно будет расширить стиль Theme.Dialog.

+0

Спасибо дружище, что на самом деле Полезные веселит, kariyachan – DroidBot 2010-12-08 12:25:47

1

Можно ли назвать устройства, которые используются для тестирования? Возможно, они могут содержать настраиваемую Android-сборку, поэтому цвет диалога изменяется. Вы можете оставить его как есть, так как ваша сборка будет использовать стиль по умолчанию, доступный для устройства, и попробуйте установить стили, чтобы избежать такого поведения.

1

Используйте активность в качестве диалога, установив для него тему диалога. Затем вы можете раздуть свой собственный макет своим собственным фоном и цветами.

1

Изменить цвет DialogBox и сделать больше с AlertDialog.

Что вы должны сделать:

AlertDialog Когда видна на экране, OnShowListener называется. Итак, добавив dialog.setOnShowListener(this), вы сможете настроить свой AlertDialog.

Код:

// Create AlertDialog 
AlertDialog.Builder adb = new AlertDialog.Builder(context1); 
    adb.setTitle(context1.getString(R.string.app_name)) 
    .setMessage(message) 
    .setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int which) { 

     } 
}); 
AlertDialog dialog = adb.create(); 

// Make some UI changes for AlertDialog 
dialog.setOnShowListener(new DialogInterface.OnShowListener() { 
    @Override 
    public void onShow(final DialogInterface dialog) { 

     // Add or create your own background drawable for AlertDialog window 
     Window view = ((AlertDialog)dialog).getWindow(); 
     view.setBackgroundDrawableResource(R.drawable.your_drawable); 

     // Customize POSITIVE, NEGATIVE and NEUTRAL buttons. 
     Button positiveButton = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_POSITIVE); 
     positiveButton.setTextColor(context1.getResources().getColor(R.color.primaryColor)); 
     positiveButton.setTypeface(Typeface.DEFAULT_BOLD); 
     positiveButton.invalidate(); 

     Button negativeButton = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEGATIVE); 
     negativeButton.setTextColor(context1.getResources().getColor(R.color.primaryColor)); 
     negativeButton.setTypeface(Typeface.DEFAULT_BOLD); 
     negativeButton.invalidate(); 

     Button neutralButton = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEUTRAL); 
     neutralButton.setTextColor(context1.getResources().getColor(R.color.primaryColor)); 
     neutralButton.setTypeface(Typeface.DEFAULT_BOLD); 
     neutralButton.invalidate(); 
    } 
}); 
Смежные вопросы