Android覆盖默认对话框主题

All*_*ast 2 android android-layout android-theme

我想为看起来像对话框的活动创建自定义样式.但我想将此对话框放在屏幕的右上角,并将背景设置为透明.

我已将活动主题设置为@android:style/Theme.Dialog但现在我想覆盖现有主题但我没有在我的sdk文件夹中找到此主题.

有人能告诉我如何更改默认对话框主题?

Par*_*ani 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>
Run Code Online (Sandbox Code Playgroud)

  • @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.其中定义的所有属性通常都是您可以更改的属性. (2认同)