AlertDialog背景颜色 [英] AlertDialog background color

查看:280
本文介绍了AlertDialog背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是AlertDialog自定义布局。 TextView的在布局的颜色是黑色,所以用Holo.Light在Android 4.0打开对话框时,该文本是可见的。然而,如果你打开​​了Android 2.2的对话框中的文本是因为灰色背景不可见。有没有办法来改变背景颜色?

I'm using an AlertDialog with custom layout. The color of TextView in the layout is black, so when opening the dialog on Android 4.0 with Holo.Light, the text is visible. However if you open the dialog in Android 2.2 the text is not visible because of the gray background. Is there a way to change the background color?

推荐答案

只要定义在layout.xml文件的根视图的背景到您想要颜色的对话框。

Just define the background of the root view in the layout.xml file for your dialog to a color that you want.

这样的:

<?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" >
...

这篇关于AlertDialog背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆