React Native <ScrollView>持久滚动条 [英] React Native <ScrollView> persistent scrollbar

查看:51
本文介绍了React Native <ScrollView>持久滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在细读 React Native 文档 后,我无法似乎找到了如何使 <ScrollView> 具有不淡出的持久滚动条.我将如何实现这一目标?

After perusing the React Native Documentation I couldn't seem to find out how to make a <ScrollView> have a persistent scrollbar that doesn't fade out. How would I achieve that?

推荐答案

iOS

底层 iOS 原生组件 UIScrollView(从技术上讲,RCTEnhancedScrollView)不支持保持滚动指示器可见.出于这个原因,它周围的 React Native 包装器也不会.

iOS

The underlying iOS native component, UIScrollView (technically, RCTEnhancedScrollView), doesn't support keeping the scroll indicators visible. For this reason, the React Native wrapper around it won't either.

有一个技巧可以让这个与原生组件一起工作(参见这个答案了解一种方法).要在 React Native 中完成此操作,您需要在本机端实现此 hack,然后 创建您自己的 Native Module 或 fork React Native 并修改 他们的 ScrollView 组件.

There is a hack to get this working with the native component (see this answer for one approach). To accomplish this in React Native, you'd need to implement this hack on the native side, and then either create your own Native Module or fork React Native and modify their ScrollView component.

也就是说,iOS Scroll View 界面指南 不鼓励这样做,因此您可能希望不考虑指标的行为.

That said, the iOS Scroll View interface guidelines discourage this, so you may want to leave the indicators' behavior alone.

一些方法:

  • set 总是,
  • 在 XML 中设置 android:fadeScrollbars="false",或者
  • 在 Java 中设置 ScrollView.setScrollbarFadingEnabled(false)(例如,在您的自定义本机桥代码中)
  • set <item name="android:overScrollMode">always</item>,
  • set android:fadeScrollbars="false" in XML, or
  • set ScrollView.setScrollbarFadingEnabled(false) in Java (e.g. in your custom native bridge code)

除非您有充分的理由,否则与非标准 UI 一样不鼓励这样做.

This is similarly discouraged as nonstandard UI unless you have a strong reason for it.

这篇关于React Native &lt;ScrollView&gt;持久滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆