问题描述
我已将 PreferenceScreen 添加到我的项目中。现在我想设计它。我唯一需要做的就是更改文本颜色。所以我在我的偏好中附加了一个主题,如下所示:
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
.......
.......
<item name="preferenceTheme">@style/Theme.MyApp.Prefs</item>
</style>
<style name="Theme.MyApp.Prefs" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="android:textColor">@color/dark_blue</item>
<item name="android:colorForeground">@color/dark_blue</item>
</style>
所以它改变了我大部分元素的颜色,但现在我遇到了新问题。 SwitchPreferenceCompat
的样式消失了,或者类似的东西。
(第一张图是我的ui,没有主题附件,第二张有附件):
但在 android studio 预览中,一切看起来都很棒:
这是我的 PreferenceScreen xml:
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/tasks_remove_schedule_category_title">
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="auto_remove_tasks"
app:summaryOff="@string/auto_remove_task_summary_off"
app:summaryOn="@string/auto_remove_task_summary_on"
app:title="@string/auto_remove_task_title" />
<ListPreference
app:defaultValue="last_year"
app:dependency="auto_remove_tasks"
app:entries="@array/remove_task_schedule_entries"
app:entryValues="@array/remove_task_schedule_values"
app:iconSpaceReserved="false"
app:key="remove_task_schedule"
app:summary="@string/auto_remove_task_options_summary"
app:title="@string/auto_remove_task_options_title"
app:useSimpleSummaryProvider="true" />
<Preference
app:key="remove_old_tasks"
app:icon="@drawable/ic_trash_bin"
app:iconSpaceReserved="false"
app:title="@string/remove_old_tasks_Now_title"
app:summary="@string/remove_old_tasks_Now_summary"/>
</PreferenceCategory>
<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/other_settings_category_title">
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="hideOutDates"
app:summaryOff="@string/hide_out_dates_switch_summary_off"
app:summaryOn="@string/hide_out_dates_switch_summary_on"
app:title="@string/hide_out_dates_switch_title" />
</PreferenceCategory>
</PreferenceScreen>
我应该怎么做才能解决这个问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)