Разрыв строки в строках ресурсов не работает. Android - PullRequest
0 голосов
/ 19 ноября 2018

Этот вопрос существует два раза:

Разрыв строки \ n не работает, он отображается как строка

String Resource новая строка / n нетвозможно?

Но ни \ n, ни нажатие клавиши enter в strings.xml не дают мне разрыв строки в textView, в котором я устанавливаю текст.Кто-нибудь знает почему?

My textView:

   <TextView
    android:id="@+id/textView"
    android:layout_width="952dp"
    android:layout_height="172dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    android:ems="10"
    android:inputType="textPersonName"
    android:text="@string/give_username"
    android:textSize="45sp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.003" />

Как задать текст:

this.textView.setText(R.string.give_sex_age);

Строка в ресурсах:

<string name="give_sex_age">You are a new user.\nPlease give your sex and your age</string>

1 Ответ

0 голосов
/ 19 ноября 2018

Как было сказано в комментариях seeming.amusing, именно inputType является причиной игнорирования разрыва строки. Я просто удаляю эту строку

android:inputType="textPersonName"

Теперь это работает!

...