Android开发:AlertDialog自定义样式


像列表这种选择项的弹出式对话框,要改变样式一般都采取重写layout方式

今天才了解到 其实可以自定义样式,与大家分享下,其实很简单

  1. AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));  

然后自定义自己的样式就可以了

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <style name="AlertDialogCustom" parent="@Android:style/AlertDialog">  
  4.         <item name="android:textColor">#00FF00</item>  
  5.         <item name="android:typeface">monospace</item>  
  6.         <item name="android:textSize">10sp</item>  
  7.     </style>  
  8. </resources>  

相关内容