【问题标题】:How to display vertical scroll indicator always in react native scrollview如何在反应原生滚动视图中始终显示垂直滚动指示器
【发布时间】:2019-09-20 00:52:11
【问题描述】:

我一直在尝试显示垂直滚动指示器。因为我的屏幕上有 4 页,但是,在加载屏幕并滚动第一页后,垂直滚动指示器正在消失,这是滚动视图的默认行为。所以,我尝试展示一些 flashScrollIndicators() 但是,它仍然在消失。

  setScrollView = (scrollView) => {
    // NOTE: scrollView will be null when the component is unmounted
    this.scrollView = scrollView;
    this.scrollView.flashScrollIndicators();
  };


  render() {

return (
      <ScrollView ref={this.setScrollView} style={{ marginTop: 10, flexGrow: 1, flex: 1 }} contentInset={{ bottom: 20 }}>
   );
 }

任何建议,我的要求是我必须始终在屏幕上显示滚动指示器。

【问题讨论】:

标签: react-native scrollview


【解决方案1】:

flashScrollIndicators() 将闪烁指示器一到两秒钟。您需要继续调用它才能看到它(例如使用 setInterval)。但这会使它像圣诞树一样闪烁,因为每次调用它都会闪烁,而不是保持稳定。

如果您希望栏始终是实心的,那么您可以在 iOS 上使用 my suggestion(没有本机代码)。 Android 有 persistentScrollbar 属性,使用起来非常简单。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-05-02
  • 2013-10-23
  • 1970-01-01
  • 2016-07-22
  • 1970-01-01
  • 2018-02-02
  • 1970-01-01
相关资源
最近更新 更多