我想从react-native-paper库中为IconButton组件设置背景色。我在文档中没有找到任何关于backgroundColor的建议。我尝试在style中使用backgroundColor。这在IOS上有效,但在安卓上不起作用,而且我尝试使用background属性,在安卓上它导致错误:`更新RCTView管理的视图的属性'nativeBackgroundAndroid‘时出错
无法将java.lang.String强制转换为abi41__0。com.facebook.react.bridge.ReadableMap `
这种带有backgroundColor风格的解决方案仅适用于IOS:
<IconButton
style={{
backgroundColor: "#DBD7D2", //works on IOS only
position: 'absolute',
top: hp('7%'),
alignSelf: 'flex-end',
right: wp('0.2%'),
}}
icon="layers-outline"
color={Colors.black}
size={hp('3.5%')}
onPress={() => setSatellite((prev) => !prev)}
/>有什么建议吗?
发布于 2021-08-26 14:45:51
我没有找到一种使用react-native-paper的方法,所以我使用了<TouchableOpacity>和<IonIcons> Example:
<TouchableOpacity activeOpacity={.5} onPress={() => setSatellite((prev) => !prev)} style={{
right: wp('2%'),
position: 'absolute',
top: hp('7%'),
alignSelf: 'flex-end',
width: wp('12%'),
height: hp('5%'),
justifyContent: "center",
marginTop: wp('2%'),
backgroundColor: "#DBD7D2",
borderRadius: hp('1%'),
}}>
<Ionicons
style={{alignSelf: "center"}} color={'#000000'} size={hp('4%')}
name={"layers-outline"}/>
</TouchableOpacity>https://stackoverflow.com/questions/68926781
复制相似问题