【问题标题】:Setting a theme for my custom DialogPreference?为我的自定义 DialogPreference 设置主题?
【发布时间】:2012-08-14 02:45:24
【问题描述】:

我有一个自定义的DialogPreference,用于SeekBar。我覆盖 style="@style/Theme.Putio.Dialog" 并从 XML 扩展布局。

问题是,生成的对话框使用默认的 Android 对话框样式,我希望它使用我的。

我在哪里告诉它使用我的对话框?如有需要,我会发布代码。

【问题讨论】:

标签: android dialog android-theme


【解决方案1】:

您可以在styles.xml 中为您的对话框定义自定义样式

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/dialogback</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item></style>

并在创建对话框时使用以下代码。

final Dialog CustomDialog = new Dialog(MyActivity.this,R.style.CustomDialogTheme);

【讨论】:

  • 我在我的应用程序的另一部分使用它,它工作正常。但这次我使用的是 DialogPreference,您没有显式创建对话框 (afaik)。
猜你喜欢
  • 2013-07-04
  • 2013-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多