fan*_*555 7 android android-alertdialog
我正在使用具有自定义布局的AlertDialog.TextView中的布局的颜色是黑色的,所以用Holo.Light在Android 4.0打开对话框时,该文本是可见的.但是,如果您在Android 2.2中打开对话框,则由于灰色背景,文本不可见.有没有办法改变背景颜色?
但是,如果您在Android 2.2中打开对话框,则由于灰色背景,文本不可见.有没有办法改变背景颜色?
是的,我可以使用DialogBuilder在我的应用程序上使用它.只需将inverseBackgroundForced置为true即可
builder.setInverseBackgroundForced(true);
AlertDialog dialog = builder.create();
dialog.show();
Run Code Online (Sandbox Code Playgroud)
在对话框构建器上.在Froyo之前,它会在android版本上强制背景为白色(而不是深灰色).
只需在对话框的layout.xml 文件中将根视图的背景定义为您想要的颜色即可。
像这样:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/dialog_background" >
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20962 次 |
| 最近记录: |