AlertDialog背景的修改
AlertDialog背景的修改是不允许使用xml的去修改的
如果你是用
<style name="MyOpaqueActivity" parent="@android:style/Theme.Dialog">?
? ? <item name="android:windowBackground">@drawable/my_background</item>?
? ? <item name="android:alertDialogStyle">@style/MyOpaqueAlertDialog</item>?
</style>?
?
<style name="MyOpaqueAlertDialog" parent="@android:style/Theme.Dialog.Alert">?
? ? <item name="android:background">#454545</item>?
? ? <item name="android:windowBackground">@drawable/my_background</item>?
? ? <item name="android:popupBackground">@drawable/my_background</item>?
</style>?
然后应用到你的整个程序中你会发现 背景色改了my_background起作用了,但是MyOpaqueAlertDialog不能起作用
也就是说AlertDialog不能在xml中该
只能硬编码
protected AlertDialog(Context context) {?
? ? this(context, com.android.internal.R.style.Theme_Dialog_Alert);?
}?
?
public Builder(Context context) {?
? ? this(context, com.android.internal.R.style.Theme_Dialog_Alert);?
}?
protected AlertDialog(Context context) {
this(context, com.android.internal.R.style.Theme_Dialog_Alert);
}
public Builder(Context context) {
this(context, com.android.internal.R.style.Theme_Dialog_Alert);
}
看不明白。。。请问是什么意思?继承修改吗?但是继承修改哦,因为Builder的oncreat()返回的是AlertDialog类型的,oncreat用到了不公开的东西=,=
所以还是不明白怎么修改。麻烦解析一下可以吗?
我就是想要AlertDialog(context,theme)初始化示例,但是protected=。=要怎么做?
谢谢指导 2 楼 ishelf 2010-11-09 这里的Dialog是可以通过xml修改的,按照需求修改res中的popup_开头的12个图片文件,这样就可以达到修改背景的目的