机器人:对话preference颜色/风格? [英] Android: DialogPreference color/style?

查看:108
本文介绍了机器人:对话preference颜色/风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要preference活动设置为@安卓风格/ Theme.Light。我的一个preferences是一个对话框preference谁的对话框包含一个ListView。 ListView的对话框是暗灰色的(因为对话框preference使用AlertBuilder创造深灰色对话框),并在列表中的文字为黑色(因为Theme.Light导致列表视图有黑色文本)。有没有一种简单的方法要么得到ListView控件的行为具有相同风格的深色对话?或获得的行为具有相同风格的光活性黑暗对话框?

My main preference activity is set to "@android:style/Theme.Light". One of my preferences is a DialogPreference who's Dialog contains a ListView. The ListView's dialog is dark grey (because DialogPreference uses AlertBuilder which creates dark grey dialogs) and the text in the list is black (because Theme.Light causes listViews to have black text). Is there an easy way to either get the ListView to behave with the same style as the dark dialog? Or to get the dark dialog to behave with the same style as the light activity?

编辑:

根据梅林的评论,好像我应该尝试做的是创造一个Li​​ghtDialog主题。为了做到这一点,我试过:1,扩大Android的Theme.Light和Theme.Dialog添加dialogy性质

Based on Merlin's comments, it seems like what I should try to do is create a LightDialog Theme. In order to do this I tried: 1. extending android's Theme.Light and adding the dialogy properties from Theme.Dialog

<style name="Theme.LightDialog" parent="@android:style/Theme.Light">
  <item name="android:windowFrame">@null</item> 
  <item name="android:windowTitleStyle">@android:style/DialogWindowTitle</item> 
  <item name="android:windowBackground">@android:drawable/panel_background</item> 
  <item name="android:windowIsFloating">true</item> 
  <item name="android:windowContentOverlay">@null</item> 
  <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> 
</style>

...和2。扩大Android的Theme.Dialog和Theme.Light添加莱蒂属性。

... and 2. extending android's Theme.Dialog and adding the lighty properties from Theme.Light.

   <style name="Theme.LightDialog" parent="@android:style/Theme.Dialog">
          <item name="android:windowBackground">@drawable/screen_background_light</item> 
          <item name="android:colorBackground">@android:color/background_light</item> 
          <item name="android:colorForeground">@androidcolor/bright_foreground_light</item> 
          <item name="android:colorForegroundInverse">@android:color/bright_foreground_light_inverse</item> 
          <item name="android:textColorPrimary">@android:color/primary_text_light</item> 
          <item name="android:textColorSecondary">@android:color/secondary_text_light</item> 
          <item name="android:textColorTertiary">@android:color/tertiary_text_light</item> 
          <item name="android:textColorPrimaryInverse">@android:color/primary_text_dark</item> 
          <item name="android:textColorSecondaryInverse">@android:color/secondary_text_dark</item> 
          <item name="android:textColorTertiaryInverse">@android:color/tertiary_text_dark</item> 
          <item name="android:textColorPrimaryDisableOnly">@android:color/primary_text_light_disable_only</item> 
          <item name="android:textColorPrimaryInverseDisableOnly">@android:color/primary_text_dark_disable_only</item> 
          <item name="android:textColorPrimaryNoDisable">@android:color/primary_text_light_nodisable</item> 
          <item name="android:textColorSecondaryNoDisable">@android:color/secondary_text_light_nodisable</item> 
          <item name="android:textColorPrimaryInverseNoDisable">@android:color/primary_text_dark_nodisable</item> 
          <item name="android:textColorSecondaryInverseNoDisable">@android:color/secondary_text_dark_nodisable</item> 
          <item name="android:textColorHint">@android:color/hint_foreground_light</item> 
          <item name="android:textColorHintInverse">@android:color/hint_foreground_dark</item> 
    </style> 

这两个尝试失败了,因为他们使用非公开的属性。关于如何创建一个LightDialog主题有什么建议?

Both of these attempts failed because they use non-public attributes. Any suggestions on how to create a LightDialog theme?

推荐答案

您可以在Android中创建样式时继承defult主题。

You can inherit defult themes when creating styles in Android.

请阅读应用样式和主题的专门章节关于继承

Please read the documentation on Applying Styles and Themes specifically the section on inheritance

您应该能够采取Theme.light,并更正您有任何问题。

You should be able to take Theme.light and correct any issues that you have with it.

您可能会发现,不同的供应商改变他们的设备上的主题,所以如果你的目标范围广泛的硬件,那么你可能会更好创建一个完整的主题,以确保您的应用程序是在所有平台上是一致的。

You may find that different vendors alter the themes on their devices so if you are targeting a broad range of hardware then you may be better creating a full theme to ensure that your app is consistent on all platforms.

更新

正如这个答案说明<一href="http://stackoverflow.com/questions/5850597/consistent-ui-color-in-all-android-devices/5851018#5851018">Consistent在所有的Andr​​oid设备用户界面的颜色中有公立和非公立属性。答案提供了一个链接到公共属性的列表但kernel.org仍然关闭,因此您需要挖通源核心/res/res/values​​/public.xml

As stated in this answer Consistent UI color in all Android devices there are public and non-public attributes. The answer provides a link to a list of public attributes however kernel.org is still down so you will need to dig through the source for core/res/res/values/public.xml

这篇关于机器人:对话preference颜色/风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆