最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React-Native multiline TextInput component: how to allow scroll when editable set to false - Stack Overflow

programmeradmin5浏览0评论

I'm currently building an app that allows a user to call API endpoints and display the JSON API response in an uneditable text input.

The issue I'm facing is when the keyboard is disabled I'm able to scroll inside the text input box but when editable is set to false and the keyboard doesn't show up then I'm unable to scroll inside the text input

<TextInput
    multiline={true}
    style={styles.multilineText}
    value={JSON.stringify([this.state.apiResponse], null, '\t')}
    editable={false}
    />

Please help

I'm currently building an app that allows a user to call API endpoints and display the JSON API response in an uneditable text input.

The issue I'm facing is when the keyboard is disabled I'm able to scroll inside the text input box but when editable is set to false and the keyboard doesn't show up then I'm unable to scroll inside the text input

<TextInput
    multiline={true}
    style={styles.multilineText}
    value={JSON.stringify([this.state.apiResponse], null, '\t')}
    editable={false}
    />

Please help

Share Improve this question edited Feb 8, 2019 at 12:05 Firdous nath 1,5871 gold badge17 silver badges40 bronze badges asked Feb 7, 2019 at 22:20 Chris MarshallChris Marshall 8082 gold badges13 silver badges31 bronze badges 3
  • 1 If you want to display non editable text , why don't you use simple Text ponent inside ScrollView ! – Firdous nath Commented Feb 8, 2019 at 11:27
  • Very good point and a massive oversight on my part done the trick, cheers – Chris Marshall Commented Feb 8, 2019 at 19:56
  • I am glad to help, you may upvote my ment :) – Firdous nath Commented Feb 9, 2019 at 5:01
Add a ment  | 

1 Answer 1

Reset to default 4

Making the text input to scroll in react native, you have to add numberOflines to it, this is the property which takes the value as int, how much lines you want to display in text input you have to provide the number and after that, the text input will get scroll property automatically.

<TextInput
        {...this.props} // Inherit any props passed to it; e.g., multiline, numberOfLines below
        editable = {false}
        multiline = {true}
        numberOfLines={3}
      />

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论