我刚刚发现ScrollView没有永久的滚动条.我浏览了所有的文档和谷歌,但我认为它实际上并不存在.

我们如何实现<ScrollView>的永久滚动条?我们如何保持滚动条可见?

推荐答案

有滚动条是在<scrollview>...

here is the code...

import React, { Component } from 'react';
import { Text, Image, View, StyleSheet, ScrollView } from 'react-native';

class ScrollViewExample extends Component {
   state = {
      names: [
         {'name': 'Ben', 'id': 1},
         {'name': 'Susan', 'id': 2},
         {'name': 'Robert', 'id': 3},
         {'name': 'Mary', 'id': 4},
         {'name': 'Daniel', 'id': 5},
         {'name': 'Laura', 'id': 6},
         {'name': 'John', 'id': 7},
         {'name': 'Debra', 'id': 8},
         {'name': 'Aron', 'id': 9},
         {'name': 'Ann', 'id': 10},
         {'name': 'Steve', 'id': 11},
         {'name': 'Olivia', 'id': 12}
      ]
   }
   render() {
      return (
         <View>
            <ScrollView>
               {
                  this.state.names.map((item, index) => (
                     <View key = {item.id} style = {styles.item}>
                        <Text>{item.name}</Text>
                     </View>
                  ))
               }
            </ScrollView>
         </View>
      )
   }
}
export default ScrollViewExample

const styles = StyleSheet.create ({
   item: {
      flexDirection: 'row',
      justifyContent: 'space-between',
      alignItems: 'center',
      padding: 30,
      margin: 2,
      borderColor: '#2a4944',
      borderWidth: 1,
      backgroundColor: '#d2f7f1'
   }
})

只需使用导入滚动视图

React-native相关问答推荐

FlatList有时不会在数据更改时重新呈现

错误:图片:找不到 ID 为1的assets资源 .请判断图像源或打包器

何时在 React Native 中使用辅助功能 Role='link'?

React Native TextInput 在android上打开时会自动关闭

按下按钮有一个borderRadius

React Native:在 ScrollView contentContainerStyle 上设置 flex:1 会导致组件重叠

为应用创建单个 MobX store 的最佳方式是什么?

TabNavigator 中的 React Navigation 传递props

textAlignVertical不是有效的样式属性

当 textInput 聚焦时,第一次touch flatList 不起作用,但是第二次起作用

如何在 React Native 中按住以 Select 文本

React Native:组件卸载时的动画

React native expection java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/{package}/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit

组件div的视图配置 getter 回调必须是一个函数(收到 undefined)

React Native Android 文本组件额外填充

Animated.View 的样式props的Typescript定义

如何在样式组件之外获取主题?

在 React Native 中使用小数

如何使 react-native Picker 停留在新 Select 的选项?

React Native:使用选项卡动画收缩标题