1
A
回答
1
你在anddev.org上有一些線索。基本想法是擴展默認主題並將其用於您的活動中。特別是,你需要擴展Theme.Dialog風格。
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();
}
});
相關問題
- 1. 如何更改對話框的邊框顏色?
- 2. ASP.NET的jQuery的改變錶行的顏色後confrim對話框
- 3. Android的對話框顏色
- 4. 的Graphviz:如何改變邊框顏色
- 5. 用jQuery對話框改變每一行的顏色.append
- 6. 進度顏色改變了這一切進度對話框顏色
- 7. 如何更改PreferenceFragment警報對話框的分隔線顏色
- 8. 如何更改Android對話框背後的顏色
- 9. 如何更改對話框的標題背景顏色?
- 10. 如何更改對話框的標題顏色?
- 11. 如何更改日曆對話框的顏色Android
- 12. 如何使用python對話框更改tui的背景顏色
- 13. 如何更改默認片段對話框的主題顏色
- 14. 如何更改對話框的背景覆蓋顏色
- 15. 如何更改Android DatePicker對話框的「分隔線」顏色
- 16. 如何更改進度對話框的背景顏色
- 17. 如何更改支持包的偏好對話框顏色?
- 18. 如何更改DatePicker對話框的顏色
- 19. 如何更改jquery ui中的對話框標題顏色?
- 20. 如何更改單選警報對話框的顏色?
- 21. 如何更改進度對話框的背景顏色?
- 22. 如何更改jquery ui對話框的背景顏色
- 23. 如何更改按鈕的顏色在警報對話框
- 24. 如何更改JQueryUI對話框標題的顏色?
- 25. 如何更改iOS中UIAlertView對話框的顏色?
- 26. 改變窗框的顏色
- 27. 如何在tabcontrol中更改對話框背景顏色?
- 28. 如何更改顏色對話框語言
- 29. 如何以編程方式更改對話框背景顏色?
- 30. 如何更改默認顏色方案timepicker對話框片段?
謝謝哥們說真的是有用的歡呼聲,kariyachan – DroidBot 2010-12-08 12:25:47