设置Android Studio中TimePicker XML的颜色时出现问题。

huangapple go评论62阅读模式
英文:

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

设置Android Studio中TimePicker XML的颜色时出现问题。

This is what it currently looks like, and the XML that accompanies it:

&lt;!-- Clock dialog --&gt;
&lt;style name=&quot;TimePicker&quot; parent=&quot;ThemeOverlay.MaterialComponents.TimePicker&quot;&gt;
    &lt;item name=&quot;colorPrimaryVariant&quot;&gt;@color/colorPrimary&lt;/item&gt;
    &lt;item name=&quot;materialClockStyle&quot;&gt;@style/TimePicker.Clock&lt;/item&gt;
    &lt;item name=&quot;materialButtonOutlinedStyle&quot;&gt;@style/TimePicker.Button&lt;/item&gt;
    &lt;item name=&quot;chipStyle&quot;&gt;@style/TimePicker.Chip&lt;/item&gt;
    &lt;item name=&quot;imageButtonStyle&quot;&gt;@style/TimePicker.ImageButton&lt;/item&gt;
&lt;/style&gt;

&lt;style name=&quot;TimePicker.Clock&quot; parent=&quot;Widget.MaterialComponents.TimePicker.Clock&quot;&gt;
    &lt;item name=&quot;clockFaceBackgroundColor&quot;&gt;@color/colorPrimary&lt;/item&gt;
    &lt;item name=&quot;clockHandColor&quot;&gt;@color/colorSecondaryVariant&lt;/item&gt;
    &lt;item name=&quot;clockNumberTextColor&quot;&gt;@color/colorOnSecondary&lt;/item&gt;
&lt;/style&gt;

&lt;style name=&quot;TimePicker.Button&quot; parent=&quot;Widget.MaterialComponents.TimePicker.Button&quot;&gt;
    &lt;item name=&quot;android:textColor&quot;&gt;@color/colorOnSecondary&lt;/item&gt;
    &lt;item name=&quot;strokeWidth&quot;&gt;0dp&lt;/item&gt;
&lt;/style&gt;

&lt;style name=&quot;TimePicker.Chip&quot; parent=&quot;Widget.MaterialComponents.TimePicker.Display&quot;&gt;
    &lt;item name=&quot;android:textColor&quot;&gt;@color/colorOnSecondary&lt;/item&gt;
&lt;/style&gt;

&lt;style name=&quot;TimePicker.ImageButton&quot; parent=&quot;Widget.MaterialComponents.TimePicker.ImageButton&quot;&gt;
    &lt;item name=&quot;iconTint&quot;&gt;@color/colorOnSecondary&lt;/item&gt;
&lt;/style&gt;

My colors for this light theme:

<resources>

&lt;!-- Light mode --&gt;
&lt;color name=&quot;blue&quot;&gt;#4984BF&lt;/color&gt;

&lt;color name=&quot;colorPrimary&quot;&gt;#ECECEC&lt;/color&gt; &lt;!-- Even Brighter Light Gray --&gt;
&lt;color name=&quot;colorPrimaryVariant&quot;&gt;#AAAAAA&lt;/color&gt; &lt;!-- Muted Gray --&gt;
&lt;color name=&quot;colorOnPrimary&quot;&gt;#000000&lt;/color&gt; &lt;!-- Black --&gt;
&lt;color name=&quot;colorSecondary&quot;&gt;#B0C7A1&lt;/color&gt; &lt;!-- Soft Green --&gt;
&lt;color name=&quot;colorSecondaryVariant&quot;&gt;#9CB68C&lt;/color&gt; &lt;!-- Muted Soft Green --&gt;
&lt;color name=&quot;colorOnSecondary&quot;&gt;#01140b&lt;/color&gt; &lt;!-- Black Green --&gt;
&lt;color name=&quot;statusBarColor&quot;&gt;#AAAAAA&lt;/color&gt; &lt;!-- Muted Gray --&gt;

</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

这是答案,这会改变突出显示的区域。

英文:
&lt;style name=&quot;TimePicker&quot; parent=&quot;ThemeOverlay.MaterialComponents.TimePicker&quot;&gt;
    &lt;item name=&quot;colorPrimary&quot;&gt;@color/colorSecondaryVariant&lt;/item&gt;
    &lt;item name=&quot;colorOnPrimary&quot;&gt;@color/colorSecondaryVariant&lt;/item&gt;
    &lt;item name=&quot;colorOnSurface&quot;&gt;@color/colorSecondaryVariant&lt;/item&gt;

this was the answer, this changes the highlighted areas

huangapple
  • 本文由 发表于 2023年5月30日 06:55:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76360728.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定