英文:
Trouble setting color for TimePicker XML Android Studio
问题
正如您所看到的,当选择AM和PM时,颜色很难看清楚,取消和确定也很难看清楚,我希望在10:00后面的高亮显示有不同的颜色。我只是不知道属性名称,我尝试了很多不同的方法,包括查看文档,我只是需要帮助理解我错过了什么/做错了什么。
这是当前的外观,以及附带的XML代码:
<!-- 时钟对话框 -->
<style name="TimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker">
<item name="colorPrimaryVariant">@color/colorPrimary</item>
<item name="materialClockStyle">@style/TimePicker.Clock</item>
<item name="materialButtonOutlinedStyle">@style/TimePicker.Button</item>
<item name="chipStyle">@style/TimePicker.Chip</item>
<item name="imageButtonStyle">@style/TimePicker.ImageButton</item>
</style>
<style name="TimePicker.Clock" parent="Widget.MaterialComponents.TimePicker.Clock">
<item name="clockFaceBackgroundColor">@color/colorPrimary</item>
<item name="clockHandColor">@color/colorSecondaryVariant</item>
<item name="clockNumberTextColor">@color/colorOnSecondary</item>
</style>
<style name="TimePicker.Button" parent="Widget.MaterialComponents.TimePicker.Button">
<item name="android:textColor">@color/colorOnSecondary</item>
<item name="strokeWidth">0dp</item>
</style>
<style name="TimePicker.Chip" parent="Widget.MaterialComponents.TimePicker.Display">
<item name="android:textColor">@color/colorOnSecondary</item>
</style>
<style name="TimePicker.ImageButton" parent="Widget.MaterialComponents.TimePicker.ImageButton">
<item name="iconTint">@color/colorOnSecondary</item>
</style>
我用于这个浅色主题的颜色:
<resources>
<!-- 浅色模式 -->
<color name="blue">#4984BF</color>
<color name="colorPrimary">#ECECEC</color> <!-- 更亮的浅灰色 -->
<color name="colorPrimaryVariant">#AAAAAA</color> <!-- 柔和的灰色 -->
<color name="colorOnPrimary">#000000</color> <!-- 黑色 -->
<color name="colorSecondary">#B0C7A1</color> <!-- 柔和的绿色 -->
<color name="colorSecondaryVariant">#9CB68C</color> <!-- 柔和的绿色 -->
<color name="colorOnSecondary">#01140b</color> <!-- 黑绿色 -->
<color name="statusBarColor">#AAAAAA</color> <!-- 柔和的灰色 -->
</resources>
在我目前正在开发的应用程序中,主题化一直是我遇到的最大问题,我不知道是不是我没有理解基本原理,还是其他什么原因。
英文:
As you can see, AM and PM have a very hard to see color when selected, Cancel and OK are very hard to see, and I would prefer a different color for the highlighting behind 10:00. I just don't know the attribute names, I've tried so many different things including looking into documentation, I just need help understanding what I am missing/doing wrong
This is what it currently looks like, and the XML that accompanies it:
<!-- Clock dialog -->
<style name="TimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker">
<item name="colorPrimaryVariant">@color/colorPrimary</item>
<item name="materialClockStyle">@style/TimePicker.Clock</item>
<item name="materialButtonOutlinedStyle">@style/TimePicker.Button</item>
<item name="chipStyle">@style/TimePicker.Chip</item>
<item name="imageButtonStyle">@style/TimePicker.ImageButton</item>
</style>
<style name="TimePicker.Clock" parent="Widget.MaterialComponents.TimePicker.Clock">
<item name="clockFaceBackgroundColor">@color/colorPrimary</item>
<item name="clockHandColor">@color/colorSecondaryVariant</item>
<item name="clockNumberTextColor">@color/colorOnSecondary</item>
</style>
<style name="TimePicker.Button" parent="Widget.MaterialComponents.TimePicker.Button">
<item name="android:textColor">@color/colorOnSecondary</item>
<item name="strokeWidth">0dp</item>
</style>
<style name="TimePicker.Chip" parent="Widget.MaterialComponents.TimePicker.Display">
<item name="android:textColor">@color/colorOnSecondary</item>
</style>
<style name="TimePicker.ImageButton" parent="Widget.MaterialComponents.TimePicker.ImageButton">
<item name="iconTint">@color/colorOnSecondary</item>
</style>
My colors for this light theme:
<resources>
<!-- Light mode -->
<color name="blue">#4984BF</color>
<color name="colorPrimary">#ECECEC</color> <!-- Even Brighter Light Gray -->
<color name="colorPrimaryVariant">#AAAAAA</color> <!-- Muted Gray -->
<color name="colorOnPrimary">#000000</color> <!-- Black -->
<color name="colorSecondary">#B0C7A1</color> <!-- Soft Green -->
<color name="colorSecondaryVariant">#9CB68C</color> <!-- Muted Soft Green -->
<color name="colorOnSecondary">#01140b</color> <!-- Black Green -->
<color name="statusBarColor">#AAAAAA</color> <!-- Muted Gray -->
</resources>
While making the app I'm currently working on, theming my app has by far been the most trouble for me, I don't know if I'm not understanding basic fundamentals about it or what.
答案1
得分: 0
这是答案,这会改变突出显示的区域。
英文:
<style name="TimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker">
<item name="colorPrimary">@color/colorSecondaryVariant</item>
<item name="colorOnPrimary">@color/colorSecondaryVariant</item>
<item name="colorOnSurface">@color/colorSecondaryVariant</item>
this was the answer, this changes the highlighted areas
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论