gpt4 book ai didi

android - Xamarin Android - 更改 TimePicker 键盘 View 的颜色

转载 作者:行者123 更新时间:2023-12-05 00:19:34 27 4
gpt4 key购买 nike

我能够更改时钟 View 的颜色设置
(这很有帮助 https://www.tutorialsbuzz.com/2019/09/android-timepicker-dialog-styling.html )
ClockView
但是我在第二个 View 中并没有那么成功(按第一个图像左下角的键盘图标)。如何更改 SubTitle、InputField 和 description 的颜色(看起来纯黑色的图像中心)?有人有想法吗?
Keyboard view
是否有我忽略的文档?对于第二个 View 的颜色托盘,有一个包含所有键(如“android:numbersTextColor”等)的列表会很棒。
我感谢您的时间和精力。谢谢 :-)
编辑
“Leon Lu - MSFT”感谢您的回答。这使得在“键盘”下设置 View 样式成为可能。是否可以为输入字段上方和下方的文本、“AM”/“PM”文本和“cancel”/“ok”设置不同的颜色?
enter image description here
不幸的是,在应用提供的样式后,时钟 View 变成了这个。
enter image description here
完整的安卓风格

<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 用于 View 元素 Y 的颜色”,那就太好了。

最佳答案

你想像下面的截图那样改变 SubTitle、InputField 和 description 的颜色吗?
enter image description here
创建 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 中使用它。
<TimePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.picker"/>
如果您使用 xamarin 表单。您应该在 <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>中的颜色即可标签。 firstview 和 second view 的 textcolor 将被更改,它同时设置它们。如果你想为不同的 View 设置不同的项目,你应该自定义 TimePicker

关于android - Xamarin Android - 更改 TimePicker 键盘 View 的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62643871/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com