更改活动索引时如何使React Native选项卡视图滚动回到选项卡顶部

问题描述

我的屏幕结构如下:

<ScrollView>
  <View style={styles.container}>
    <View style={styles.topPanel} />
    <View style={styles.titleSection}>
      <View>
        <Image style={styles.profilePicture} source={logos} />
      </View>
      <View style={styles.textComponent}>
        <TextComponent
          boldness="extraBold"
          style={styles.titleSection__title}>
          ...
        </TextComponent>
        <TextComponent
          boldness="semiBold"
          style={styles.titleSection__text}>
          ...
        </TextComponent>
      </View>
      <View style={styles.verticalLine} />
      <ratingAndLocation location={6} medianrating={4.2} />
      <View>
        <TextComponent
          boldness="semiBold"
          style={styles.titleSection__desc}>
          ...
        </TextComponent>
      </View>
      <View style={styles.verticalLine} />
    </View>
  </View>
  <TabView images={images} setgalleryIndex={setgalleryIndex} />
</ScrollView>

Tabview组件包含react-native-tabview个选项卡,这些选项卡是带有内容的scrollViews。我正在尝试像这样设置scrollView的滚动位置:

navigation.addListener('blur',() => {
  scrollViewRef.scrollTo({ y: 0,x: 0,animated: true });
});

但是它不起作用。 嵌套的滚动视图不起作用。他们不触发onScroll事件。只有父级滚动视图才能做到这一点。我想知道是否有解决此问题的方法

据我了解,您不能嵌套垂直的scrollViews,但是当更改索引时又如何使每个选项卡成为单独的scrollView并滚动到其顶部呢?

这是所有内容的样子:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...