Примечание: шаг 1 - создайте собственный класс для editText wordWrap.
Android не имеет этого свойства.Но вы можете заменить все символы прерывания с помощью ReplacementTransformationMethod.
public class WordBreakTransformationMethod extends ReplacementTransformationMethod
{
private static WordBreakTransformationMethod instance;
private WordBreakTransformationMethod() {}
public static WordBreakTransformationMethod getInstance()
{
if (instance == null)
{
instance = new WordBreakTransformationMethod();
}
return instance;
}
private static char[] dash = new char[] {'-', '\u2011'};
private static char[] space = new char[] {' ', '\u00A0'};
private static char[] original = new char[] {dash[0], space[0]};
private static char[] replacement = new char[] {dash[1], space[1]};
@Override
protected char[] getOriginal()
{
return original;
}
@Override
protected char[] getReplacement()
{
return replacement;
}
}
step 2 - In Activity , write below code,
В Android:
myEditText.setTransformationMethod(WordBreakTransformationMethod.getInstance());
В Kotlin:
myEditText.setTransformationMethod= WordBreakTransformationMethod.getInstance
В Xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/myEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textCapSentences|textMultiLine"
android:scrollHorizontally="false" />
</LinearLayout>