修改AlertDialog的宽高大小,Button的字体颜色等
来源:互联网 发布:mac dock栏 图标合并 编辑:程序博客网 时间:2024/05/29 18:56
<style name="AlertDialog" parent="@style/Theme.AppCompat.Light.Dialog"> <!-- 这里设置背景为透明,为了隐藏边框 --> <item name="android:windowBackground">@color/white</item> <item name="android:windowNoTitle">true</item> <!-- 这里是修改顶部标题背景颜色,具体颜色自己定,可以是图片 --> <item name="android:topDark">@color/white</item> <!-- 这里是修改内容区域背景颜色 --> <item name="android:centerDark">@color/white</item> <item name="android:windowIsTranslucent">true</item> <item name="buttonBarPositiveButtonStyle">@style/positive</item> <item name="buttonBarNegativeButtonStyle">@style/negative</item> </style> <style name="positive"> <item name="android:textColor">@color/colorAccent</item> </style> <style name="negative"> <item name="android:textColor">@color/colorAccent</item> </style>可以看到这里使用了style中的属性来修改Button的字体颜色:
buttonBarPositiveButtonStyle
buttonBarNegativeButtonStyle。
这里设置大小请注意:show()需要在setLayout()之前。
final AlertDialog.Builder builder = new AlertDialog.Builder(WebViewActivity.this, R.style.AlertDialog); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); double width = metrics.widthPixels * 0.9; double height = metrics.heightPixels * 0.4; AlertDialog alertDialog = builder.setMessage(message) .setPositiveButton(R.string.sure, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.confirm(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.cancel(); } }) .create(); alertDialog.show(); alertDialog.getWindow().setLayout((int)width, ViewGroup.LayoutParams.WRAP_CONTENT);
http://blog.csdn.net/gs12software/article/details/48224885
https://stackoverflow.com/questions/4406804/how-to-control-the-width-and-height-of-the-default-alert-dialog-in-android
阅读全文
0 0
- 修改AlertDialog的宽高大小,Button的字体颜色等
- 能修改按钮字体颜色的AlertDialog
- 改变Button的字体颜色
- 修改UITabBarController字体颜色 图片大小颜色的小问题
- AlertDialog更改标题颜色,字体等
- AlertDialog更改标题颜色,字体等
- AlertDialog更改标题颜色,字体等
- AlertDialog更改标题颜色,字体等
- AlertDialog更改标题颜色,字体等
- Zend Studio 9.0.1 修改默认字体\颜色的修改(字体及方法名等)
- AlertDialog 修改文本内容的颜色
- Android修改AlertDialog的背景颜色
- 修改 AlertDialog 中按钮颜色的方法
- 改变UIALertView中button的字体颜色
- 设置Button的字体颜色状态选择器
- 修改PrefernceActivity的字体颜色
- 修改SecureCRT的字体颜色
- 修改UITabBarItem的字体颜色
- RabbitMQ (八) 远程调用(RPC)
- 矩阵快速幂
- Java对不同版本的word,excel的解析
- Spring:IoC 用法(五、混合配置用法)
- String常量池
- 修改AlertDialog的宽高大小,Button的字体颜色等
- Linux查看MySQL的安装路径
- 如何在tomcat下部署php
- Codeforces Round #423 B. Black Square
- CSS多行文字垂直居中的方法
- spring实现定时器功能
- POJ 2431-Expedition(优先队列)
- J2EE进阶之schema约束,JAXP的SAX解析,DOM4J的解析,XPATH的支持 七
- 设计模式(05) 原型模式