我试图让 React Native ScrollView 水平和垂直滚动,但由于某种原因它不会这样做。我知道它不适用于 Android,但它应该适用于 iOS。
我看过这个问题:https : //github.com/facebook/react-native/issues/2962
并按照它的建议做了,但它仍然只滚动一个方向。
我是这样声明的:
<ScrollView directionalLockEnabled={false} horizontal={true} style={styles.container}>
{this.buildContent()}
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
关于如何让这个滚动两个方向的任何想法?
目前没有直接的方法来实现这一点。如果设置contentContainerStyle道具对您来说不是问题,那么您可以这样做。如果是,您始终可以使用 2 个嵌套的ScrollViews。
<ScrollView>
<ScrollView horizontal={true}>
{this.buildContent()}
</ScrollView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
尝试这个:
<ScrollView
maximumZoomScale={2}
minimumZoomScale={1}
style={{ width: 320 }}
contentContainerStyle={{ width: 321 }}
>
<View style={{ width: 321, height: 320, backgroundColor: "green" }} />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
contentContainerStyle 文档在这里,官方支持的属性react-native@0.9
| 归档时间: |
|
| 查看次数: |
5285 次 |
| 最近记录: |