这篇文章主要介绍了 Android AlertDialog 自定义样式实现代码的相关资料, 这里提供了实例代码,一个简单示例,需要的朋友可以参考下
Android 是一种基于 Linux 的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由 Google 公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用 "安卓" 或 "安致"。
Android AlertDialog 自定义样式
像列表这种选择项的弹出式对话框,要改变样式一般都采取重写 layout 方式
今天才了解到 其实可以自定义样式,与大家分享下,其实很简单
- AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));
然后自定义自己的样式就可以了
- <?xml version="1.0" encoding="utf-8" ?>
- <resources>
- <style name="AlertDialogCustom" parent="@android:style/AlertDialog">
- <item name="android:textColor">
- #00FF00
- </item>
- <item name="android:typeface">
- monospace
- </item>
- <item name="android:textSize">
- 10sp
- </item>
- </style>
- </resources>
来源: