2016-09-28 152 views
0

我想寫一個非常簡單的應用程序來測試反應原生。反應原生textInput滾動查看android

我在一個大的ScrollView中有一些TextInput組件,作爲一個註冊公式。

一切工作正常,但當我滾動單擊TextInput時,它不滾動。

我只能在空白處單擊時瀏覽頁面。任何想法如何做到這一點?

謝謝。

<ScrollView> 
    <TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/> 
    <TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/> 
    <TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/> 
    <TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/> 
</ScrollView> 
+0

http://stackoverflow.com/questions/39745442/scrollview-cant-scroll-when-focus-textinput-react-native –

+0

您可能已經解決了這個問題嗎? –

+0

我有這個問題,事實證明,這是因爲我在'TextInput'的樣式中指定了'height',但是'TextInput'的內容在Android中超過了這個高度,但是不是iOS中的(因爲系統字體覆蓋了我的字體樣式)。如果有其他人遇到這種情況,可以通過刪除硬編碼的高度或增加硬編碼來確定它可以包含內容而不會溢出。 –

回答

2

的功能和搜索一段時間後沒有答案幫助了我;所以我解決了它自己放一個<TouchableWithoutFeedback />在每個<TextInput>併發送觸摸事件回<TextInput />

<View> 
    <TextInput ref ={(ref)=>this.textInput = ref}> 
    <TouchableWithoutFeedback style={{position: 'absolute', top:0, bottom:0, left:0, right:0}} 
    onPress={()=>this.textInput.focus()}/> 
</View> 

您可以創建一個包裝的TextInput像這樣的自定義組件,並在您ScrollViews使用它們。