AndroidTV滚动行为不一致

时间:2019-10-28 19:50:30

标签: react-native android-tv

在Android TV上使用Dpad时,我发现水平FlatList和垂直FlatList有区别:

考虑以下代码:

const data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];

const App = () => {
  return (
    <View style={{ flex: 1 }}>
      <FlatList
        data={data}
        //horizontal={true}
        keyExtractor={item => item.toString()}
        renderItem={({ item, index }) => (
          <TouchableOpacity onPress={() => {}}>
            <View style={{ backgroundColor: (index % 2) ? '#CCFFFF' : '#FFCCFF', height: 150, width: 150 }}>
              <Text style={{ fontSize: 36 }}>{ `Item #${index}` }</Text>
            </View>
          </TouchableOpacity>
        )}
      />
    </View>
  );
};

水平滚动时,项目在视口的右边缘一一显示: Horizontal

但是,当垂直滚动时,有时选定的项目会“抛出”在视口的中间: Vertical

我想要水平的行为(一张一张的滚动条),但是要垂直的。我该怎么办?

0 个答案:

没有答案