Abh*_*lin 8 android react-native
我想知道如何设置fontFamily.如何在Picker.items上设置颜色和背景颜色?
<Picker
style={styles.picker} // cannot set fontFamily here
selectedValue={this.state.selected2}
onValueChange={this.onValueChange.bind(this, 'selected2')}
mode="dropdown">
<Item label="hello" value="key0" /> // cannot set backgroundColor here
<Item label="world" value="key1" />
</Picker>
Run Code Online (Sandbox Code Playgroud)
我张贴这在Github上,并得到了只有一些属性可以设置在通过风格,但一些选择器(如使用的字体)是通过原生的Android驱动的多个核心元素发生反应原住民答案.它需要通过使用styles.xml等的本机android来完成.
不幸的是,我不是一个原生的Android开发人员,所以我无法理解解决方案.我将以下代码段添加到/res/values/styles.xml,但弹出窗口的文本颜色或背景没有更改.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
<style name="SpinnerItem">
<item name="android:textColor">#ffffff</item>
<item name="android:background">#993399</item>
</style>
<style name="SpinnerDropDownItem">
<item name="android:textColor">#ffffff</item>
<item name="android:background">#993399</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我需要做出哪些其他改变?如何设置fontFamily?
Jul*_*ues 13
那是因为您需要在AppTheme中声明样式
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item>
</style>
<style name="SpinnerItem">
<item name="android:textColor">#ffffff</item>
<item name="android:background">#993399</item>
</style>
<style name="SpinnerDropDownItem">
<item name="android:textColor">#ffffff</item>
<item name="android:background">#993399</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
而已 :)
| 归档时间: |
|
| 查看次数: |
5762 次 |
| 最近记录: |