当视图位于 FlatList 内时,视图 borderRadius 样式未应用于 Android
View borderRadius style not applied on Android when view is inside a FlatList
我有一个用于在日历中选择日期的组件。如果选择了日期,数字应该有圆圈作为背景。我用 borderRadius
样式将 <Text>
包装在 <View>
中,并且组件本身可以工作。
但是当我在 <FlatList>
中渲染我的组件时,borderRadius
根本没有应用到 Android。
查看 iOS 和 Android 的屏幕截图。
我已经尝试了很多调整但没有运气,现在伸出援手。我的组件代码的 Expo 示例在这里,组件本身是 DaySelectorItem.js
,列表在 DaySelectorItem.js
代码在这里https://snack.expo.io/@esbenvb/android-square-circles
提前谢谢你:)
我通常将边框道具组合在一起,所以我通过将 borderRadius
值从 dayWrapper 移动到 SelectedDayWrapper 来让它在两个平台上工作。希望这对您有所帮助!
selectedDayWrapper: {
backgroundColor: 'red',
borderColor: 'pink',
borderWidth: 2,
borderRadius: CIRCLE_1_SIZE,
},
dayWrapper: {
width: CIRCLE_1_SIZE,
height: CIRCLE_1_SIZE,
// borderRadius: CIRCLE_1_SIZE,
alignItems: 'center',
justifyContent: 'flex-start',
},
我有一个用于在日历中选择日期的组件。如果选择了日期,数字应该有圆圈作为背景。我用 borderRadius
样式将 <Text>
包装在 <View>
中,并且组件本身可以工作。
但是当我在 <FlatList>
中渲染我的组件时,borderRadius
根本没有应用到 Android。
查看 iOS 和 Android 的屏幕截图。
我已经尝试了很多调整但没有运气,现在伸出援手。我的组件代码的 Expo 示例在这里,组件本身是 DaySelectorItem.js
,列表在 DaySelectorItem.js
代码在这里https://snack.expo.io/@esbenvb/android-square-circles
提前谢谢你:)
我通常将边框道具组合在一起,所以我通过将 borderRadius
值从 dayWrapper 移动到 SelectedDayWrapper 来让它在两个平台上工作。希望这对您有所帮助!
selectedDayWrapper: {
backgroundColor: 'red',
borderColor: 'pink',
borderWidth: 2,
borderRadius: CIRCLE_1_SIZE,
},
dayWrapper: {
width: CIRCLE_1_SIZE,
height: CIRCLE_1_SIZE,
// borderRadius: CIRCLE_1_SIZE,
alignItems: 'center',
justifyContent: 'flex-start',
},