小编For*_*ine的帖子

滚动视图中的 React-native 绝对定位元素不会显示

我正在尝试在 ScrollView 中为我的 EMT 课程的测验应用程序创建一系列“抽认卡”。用户应该点击卡片,然后将其翻转以显示答案。ScrollView 中的卡片组之间有标题。

卡片动画是通过这个容器实现的,它绝对定位卡片。我无法让卡片正确显示 - 它要么没有高度,根本没有出现,看起来被压扁,或者,如果我通过编辑 FlipView 代码删除了绝对定位,则高度会加倍,以便为前面腾出空间然后回来。

Demo代码,可以直接粘贴到index.ios.js中:

import React, { Component } from 'react';
import {
  AppRegistry,
  Text,
  View,
  ScrollView,
  TouchableOpacity
} from 'react-native';
import FlipView from 'react-native-flip-view';

const data = [
  { type: 'default', text: 'some text' },
  { type: 'header', text: 'header text'},
  { type: 'default', text: 'some more text'}
];

class TextLine extends Component {
  constructor(props) {
    super(props);
    this.state = { isFlipped: false };
  }

  _flip = () => { …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-scrollview

1
推荐指数
1
解决办法
3963
查看次数