1

我在任何地方都在使用 holoe。我为我的应用创建了自己的主题,并且可以成功地将这个主题应用到我的活动中。我的主题更改了 CheckBox、EditText、DatePicker 等的可绘制对象。问题是这个主题对 PreferenceActivity 不起作用。我觉得令人费解的是,如果我将主题设置为 Holo.Theme 或 Holo.Theme.Light,它会发生应有的变化。但是,如果我将其更改为源自 Holo.Theme.Light 的主题,则不会。然而,它确实有效的所有其他活动。我通过以下方式更改活动主题:

activity.setTheme(R.style.MyCustomTheme);

所有这些都适用于所有其他活动,但不适用于 PreferenceActivity。是否必须设置一些未记录的属性才能更改偏好活动主题?

4

2 回答 2

3

样式.xml

<style name="SettingsTheme" parent="android:Theme.Light">
   <!-- Override properties according to your need -->
   <item name="android:colorBackground">#ffffff</item>
   <item name="android:colorForeground">#aaaaaa</item>

   <item name="android:textColorPrimary">#ff0000</item>
   <item name="android:textColorSecondary">#0000ff</item>
   <item name="android:textColorTertiary">#00ff00</item>
   <item name="android:textColorPrimaryDisableOnly">#888888</item>
   <item name="android:textColorHint">#778899</item>
</style>

AndroidManifest.xml在使用中将新定义的样式应用于 Preference Activityandroid:theme

<activity android:name=".SettingsThemeActivity"
      android:label="@string/app_name"
      android:theme="@style/SettingsTheme">

编辑:尝试设置主题之前

setTheme(R.style.SettingsTheme);

setContentView(R.layout.main);
于 2014-05-04T15:37:26.777 回答
0

不,它不是无证的:“我在活动主题中放置了自定义偏好样式,但什么也没发生! ”。

对于使用其他主题(不是活动主题)的首选项/视图,您应该使用 PreferenceInit.map 方法重新映射主题。

import org.holoeverywhere.app.Application;

public class MyApplication extends Application {
  static {
    PreferenceInit.map(R.style.CustomPreferenceTheme, R.style.CustomPreferenceTheme_Light);
  }
}
于 2014-05-05T16:24:46.317 回答