2012-04-15 38 views
0

我想知道是否有一种简单的方法可以让Android始终使用自定义样式来显示Dialogs使用主题更改对话框样式

使用这段代码使用的主题和风格,你可以改变它的外表和感觉所有的,比方说,在TextViews定义的themes.xml一个主题时:

<item name="android:textViewStyle">@style/Blue.TextView</item> 

与Blue.TextView的风格被定义.XML。

对于Dialogs有没有办法做到这一点?

回答

0

是的,有。例如,

AlertDialog.Builder b = new AlertDialog.Builder(context, R.style.MyTheme); 

,或者,如果您使用的是DialogFragment,只需调用setStyle()方法,

+0

其实我的需要实现是定制单击Spinner时显示的提示框,而不是仅显示具有自定义样式的对话框。 – Anordil 2012-04-15 16:11:31

0
<style 
    name="Theme_Dialog_Translucent" 
    parent="android:Theme.Dialog"> 
    <item 
     name="android:windowBackground">@null</item> 
</style> 

下面是工作的代码::

Dialog mDialog = new Dialog(this,R.style.ThemeDialogCustom); 
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
mDialog.setCanceledOnTouchOutside(true); //But here It is not workin 
mDialog.setContentView(R.layout.popup);