2012-04-15 37 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);