ReactNative ListView分隔线不一致 [英] ReactNative ListView inconsistent separator lines
问题描述
在Android 4.4上,ListView分隔线的厚度不一致,有些不渲染. 我看不到这可能是一个代码问题,这就是我渲染它们的方式:
On Android 4.4, ListView separator lines are inconsistent in thickness, and some do not render. I can't see how this can be a code issue, this is how I render them:
separator: {
height: 1,
backgroundColor: 'grey',
}
...
<ListView
renderSeparator={(sectionID, rowID) =>
<View key={`${sectionID}-${rowID}`} style={styles.separator} />
}
.../>
以下是存在此问题的视图的屏幕截图:
Here is a screenshot of a View with this problem:
此问题在iOS或Android 6上不会发生.
This issue does not happen on iOS or Android 6.
以前有人遇到过这个问题吗?
Anyone had this problem before?
更新
我做了测试,这不是Android4问题.在Nexus One设备(在Android模拟器中)上运行时,所有API版本都会发生这种情况
I did a test, this is not Android4 issue. It happens on all API version when running on Nexus One device (in android emulator)
推荐答案
我遇到了同样的问题,并解决了将视图高度从数字更改为StyleSheet.hairlineWidth的问题,就像某些人之前所说的那样.尝试变得更具视觉效果/更具针对性:
I had the same issue and solved changing the view height from a number to StyleSheet.hairlineWidth as some folks said before. Trying to be more visual/specific:
之前:
renderItemSeparator() {
return (
<View style={{ height: .2, backgroundColor: 'rgba(0,0,0,0.3)' }} />
);
}
之后:
renderItemSeparator() {
return (
<View style={{ height: StyleSheet.hairlineWidth, backgroundColor: 'rgba(0,0,0,0.3)' }} />
);
}
这篇关于ReactNative ListView分隔线不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!