React Native-按内容设置视图高度

时间:2018-09-01 17:39:49

标签: react-native flexbox

我有一个视图和一个滚动视图,由于flex:1属性,它们当前占据了整个高度。我试图弄清楚该视图如何仅占用滚动视图内的内容占用的空间量。这可能吗?

        import speech_recognition as sr

        r = sr.Recognizer()
        emptyRecords = []
        for fname in os.listdir(TESTDIR):
            with sr.AudioFile(TESTDIR + fname) as source:
                recorded = r.record(source)
                recognized = r.recognize_sphinx(recorded)
            if len(recognized) <= 10:
                print("{} seems to be an empty record.".format(fname))
                emptyRecords.append(fname)

2 个答案:

答案 0 :(得分:3)

在View和ScrollView上都设置style={{ height: 'auto', flex: 0 }}即可。

答案 1 :(得分:0)

从View移除flex 1,然后如果将ScrollView的高度设置为500,则View也将为500。