React Native - 断字 [英] React Native - hyphenation

查看:67
本文介绍了React Native - 断字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 React Native 应用程序,在其中我会在框中显示一些文本.有时,框中的单个单词太长而无法放在一行中,因此 RN 会在单词太长时将其断开并在下一行继续文本.不幸的是,这会导致单词的连字符不佳(请参见图像中的左框).我试图找到一种解决方案来改进这一点,这样在这个例子中,结果就像右边的框,在一个合理的位置,单词被连字符连接起来.我知道有处理连字的 javascript 库.

解决方案

使用 C/C++/Java 编码:

text = 'React\u00ADNative'<文本>{文本}</文本>

I'm working on a React Native app where I show some text inside boxes. Sometimes the individual words in the boxes are too long to fit on one line so RN just breaks the word off when it would get too long and continues the text on the next line. This unfortunately leads to poor hyphenation of the words (see the left box in the image). I'm trying to find a solution to improve this such that in this example the result would be like the box on the right where the word is hyphenated at a reasonable point. I know there are javascript libraries that deal with hyphenation. This for examples breaks words into their hyphens in an array. I'm stuck here because I have no idea how to actually figure out if I need to hyphenate the word or not. Any ideas?

解决方案

use C/C++/Java Encoding:

text = 'React\u00ADNative'
<Text>{text}</Text>

这篇关于React Native - 断字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆