2011-11-04 107 views
5

當我運行此代碼時,將顯示警告對話框,但對話框周圍有一個白色邊框,邊框也很小。我不想要這個白色的邊框,我想要90度角的真實角落。我希望你明白我想要做的事情。更改AlertDialog的樣式

 AlertDialog.Builder ad = new AlertDialog.Builder(this); 
     Button bbb=new Button(MvcnContactList.this); 
     ad.setView(bbb); 
     alertDialog = ad.create(); 
     alertDialog.show(); 

enter image description here

有沒有......我想樣式的警告對話框中的邊界,所以設置只是一個沒有辦法樣式警告對話框不顯示文本的顏色或文本大小或類似的東西主題也許是解決這個問題的方法。但我不知道要覆蓋哪些屬性。

感謝,

編輯: 例如這種風格覆蓋文字顏色以00FF00,這是很酷,但其性質我應該重寫,使邊角不圓和壽去除白色boreder

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="AlertDialogCustom" parent="@android:style/AlertDialog"> 
     <item name="android:textColor">#00FF00</item> 
     <item name="android:typeface">monospace</item> 
     <item name="android:textSize">10sp</item> 
    </style> 
</resources> 
+1

也許這可以幫助你: http://stackoverflow.com/questions/2422562/how-to-change-theme-for-alertdialog – rockeye

+0

這是很好的鏈接,但我不覆蓋邊界的屬性... – Lukap

回答

15

我用包裝找到了解決方案,您可以在其中設置主題(樣式)爲當前上下文中的任何內容。我將R.style.MyTheme設置爲我的警戒對話框的樣式,並根據自己的喜好定製了該視圖。

ContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.MyTheme); 
     AlertDialog.Builder builder= new AlertDialog.Builder(ctw); 
+2

但是,爲了去除圓角和邊框,您在主題中覆蓋了哪些屬性?我有同樣的問題.. – 2012-10-05 21:19:04

+0

可以請你解釋/提供代碼示例,瞭解如何刪除白色邊框? –

1

你自己回答了你的問題,但它並沒有爲我工作,所以這裏是我的回答希望對大家誰需要它的幫助:

<style name="PauseDialog" parent="@android:style/Theme.Dialog"> 
     <item name="android:windowNoTitle">true</item> 
     <item name="android:windowBackground">@android:color/transparent</item> 

</style> 

將這個風格在res \值\風格.xml文件,並將您的活動主題設置在您的Manifest中。就像這樣:

android:theme="@style/PauseDialog"