Xamarin Android - 更改 TimePicker 键盘视图的颜色
Xamarin Android - Change colors for TimePicker keyboard view
我能够更改时钟视图的颜色设置
(很有帮助https://www.tutorialsbuzz.com/2019/09/android-timepicker-dialog-styling.html)
但是我在第二个视图中并没有那么成功(按第一个图像左下角的键盘图标)。如何改变SubTitle、InputField和description(图片中心看起来是纯黑色)的颜色?有人有想法吗?
是否有我忽略的文档?对于第二个视图的颜色托盘,最好有一个包含所有键的列表,如“android:numbersTextColor”等。
感谢您付出的时间和精力。谢谢:-)
编辑
“Leon Lu - MSFT”感谢您的回答。这使得在“键盘”下设置视图样式成为可能。是否可以为输入字段上方和下方的文本、“上午”/“下午”文本和“取消”/“确定”设置不同的颜色?
不幸的是,在应用提供的样式后时钟视图变成了这个。
完整Android样式
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from https://aka.ms/material-colors -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#f59b00</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
<item name="android:timePickerDialogTheme">@style/TimePickerLightTheme</item>
<item name="android:timePickerStyle">@style/TimePickerLightStyle</item>
<item name="android:textAllCaps">false</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#f59b00</item>
</style>
<style name="TimePickerLightTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:background">#4b4b4b</item>
<item name="android:colorAccent">#2c2f30</item>
<item name="android:textColor">#f59b00</item>
<item name="android:textColorPrimary">#ffffff</item>
</style>
<style name="TimePickerLightStyle" parent="android:Widget.Material.Light.TimePicker">
<item name="android:headerBackground">#2c2f30</item>
<item name="android:numbersTextColor">#ffffff</item>
<item name="android:numbersInnerTextColor">#ffffff</item>
<item name="android:numbersSelectorColor">#f59b00</item>
<item name="android:numbersBackgroundColor">#4b4b4b</item>
<item name="android:background">#1f1f1f</item>
<item name="android:textColorPrimary">#a1a1a1</item>
</style>
是否有包含我忽略的所有元素的键的列表?最好有一个列表,上面写着“键 X 用于视图元素 Y 的颜色”。
是否要像下面的屏幕截图那样更改 SubTitle、InputField 和描述的颜色?
创建 Theme.picker
样式。
<style name="Theme.picker" parent="Theme.AppCompat.Light.Dialog">
//background color
<item name="android:background">#FFC107</item>
//Title background color
<item name="colorAccent">#FF0000</item>
//text color
<item name="android:textColor">@android:color/white</item>
//edittext color
<item name="android:textColorPrimary">@android:color/holo_green_light</item>
</style>
他们在时间选择器中使用它。
<TimePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.picker"/>
如果您使用了 xamarin forms.You 应该在 <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
中添加一个项目
<item name="android:timePickerDialogTheme">@style/Theme.picker</item>
=====更新======
Is it possible to set different colors for the text above and below the input field, the "AM"/"PM" text and "cancel"/"ok"?
如果要设置,只需在 <item name="android:textColor">@android:color/red</item>
选项卡中更改颜色即可。第一个视图和第二个视图的文本颜色将被更改,它同时设置了它们。如果你想为不同的视图设置不同的项目,你应该自定义 TimePicker
我能够更改时钟视图的颜色设置 (很有帮助https://www.tutorialsbuzz.com/2019/09/android-timepicker-dialog-styling.html)
但是我在第二个视图中并没有那么成功(按第一个图像左下角的键盘图标)。如何改变SubTitle、InputField和description(图片中心看起来是纯黑色)的颜色?有人有想法吗?
是否有我忽略的文档?对于第二个视图的颜色托盘,最好有一个包含所有键的列表,如“android:numbersTextColor”等。
感谢您付出的时间和精力。谢谢:-)
编辑
“Leon Lu - MSFT”感谢您的回答。这使得在“键盘”下设置视图样式成为可能。是否可以为输入字段上方和下方的文本、“上午”/“下午”文本和“取消”/“确定”设置不同的颜色?
不幸的是,在应用提供的样式后时钟视图变成了这个。
完整Android样式
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from https://aka.ms/material-colors -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#f59b00</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
<item name="android:timePickerDialogTheme">@style/TimePickerLightTheme</item>
<item name="android:timePickerStyle">@style/TimePickerLightStyle</item>
<item name="android:textAllCaps">false</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#f59b00</item>
</style>
<style name="TimePickerLightTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:background">#4b4b4b</item>
<item name="android:colorAccent">#2c2f30</item>
<item name="android:textColor">#f59b00</item>
<item name="android:textColorPrimary">#ffffff</item>
</style>
<style name="TimePickerLightStyle" parent="android:Widget.Material.Light.TimePicker">
<item name="android:headerBackground">#2c2f30</item>
<item name="android:numbersTextColor">#ffffff</item>
<item name="android:numbersInnerTextColor">#ffffff</item>
<item name="android:numbersSelectorColor">#f59b00</item>
<item name="android:numbersBackgroundColor">#4b4b4b</item>
<item name="android:background">#1f1f1f</item>
<item name="android:textColorPrimary">#a1a1a1</item>
</style>
是否有包含我忽略的所有元素的键的列表?最好有一个列表,上面写着“键 X 用于视图元素 Y 的颜色”。
是否要像下面的屏幕截图那样更改 SubTitle、InputField 和描述的颜色?
创建 Theme.picker
样式。
<style name="Theme.picker" parent="Theme.AppCompat.Light.Dialog">
//background color
<item name="android:background">#FFC107</item>
//Title background color
<item name="colorAccent">#FF0000</item>
//text color
<item name="android:textColor">@android:color/white</item>
//edittext color
<item name="android:textColorPrimary">@android:color/holo_green_light</item>
</style>
他们在时间选择器中使用它。
<TimePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.picker"/>
如果您使用了 xamarin forms.You 应该在 <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:timePickerDialogTheme">@style/Theme.picker</item>
=====更新======
Is it possible to set different colors for the text above and below the input field, the "AM"/"PM" text and "cancel"/"ok"?
如果要设置,只需在 <item name="android:textColor">@android:color/red</item>
选项卡中更改颜色即可。第一个视图和第二个视图的文本颜色将被更改,它同时设置了它们。如果你想为不同的视图设置不同的项目,你应该自定义 TimePicker