2012-03-26 106 views
1

我想爲看起來像對話框的活動創建自定義樣式。但是我想把這個對話框放在屏幕的右上角,同時設置背景爲透明。Android覆蓋默認對話框主題

我已將活動主題設置爲@android:style/Theme.Dialog,但現在我想覆蓋現有主題,但是我沒有在我的sdk文件夾中找到此主題。

有人能告訴我如何更改默認的對話框主題?

回答

11

您可以定義樣式來自定義任何視圖。

例如:

<style name="Theme.Dialog"> 
    <item name="android:windowFrame">@null</item> 
    <item name="android:windowTitleStyle">@android:style/DialogWindowTitle</item> 
    <item name="android:windowBackground">@android:drawable/transparent</item> 
    <item name="android:windowIsFloating">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> 
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> 
</style> 
+0

大。你的回覆。你怎麼知道什麼屬性有對話框對象?以及什麼類型的動畫等 – Allrast 2012-03-26 15:02:30

+2

@Allrast:要知道所有可用的選項,你可以檢查出android源代碼,並在[styles.xml]中查找(https://github.com/android/platform_frameworks_base/blob/master/ core/res/res/values/styles.xml)和[themes.xml](https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml)。在這種情況下,對於對話框,checkout themes.xml - > Theme.Dialog。裏面定義的所有屬性通常都是你可以改變的。 – 2013-04-22 03:45:07