Android TextView automatic line break at weird place

Viewed 337

I'm stuck on a issue with automatic linebreak at weird place in a multiline TextView. Does anyone have an idea on what I am doing wrong ?

Here's the xml layout:

<TextView
    android:id="@+id/tvDescription2"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="16dp"
    android:inputType="textMultiLine"
    android:singleLine="false"
    android:text="test"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvDescriptionTitle2" />

Here's the resource string:

<string name="labelFamilleParaben">Paraben: les propriétés antibactérienne et antifongique font qu\'il est généralement utilisé comme conservateur dans les cosmétiques. L\'utilisation de parabènes porte à controverse en raison de leur capacité à activer les récepteurs des œstrogènes, induisant une possible action sur la fertilité et les tumeurs œstrogéno-dépendantes, comme le cancer du sein. Ils ont également la réputation d\’avoir un pouvoir allergisant de contact et leur exploitation dans les produits cosmétiques est réglementée.</string>

Here's the java code:

                String descriptionContent2="<ul>";
                for(IngredientFamille ingredientFamille:ingredient.getDescription().getFamilles()){
                    if(ingredientFamille.getLabel()!=null)
                        descriptionContent2 += "<li>&nbsp;" + getContext().getString(ingredientFamille.getLabel())+"</li>";
                }
                descriptionContent2 += "</ul>";

                TextView tvDescription2 = view.findViewById(R.id.tvDescription2);
                tvDescription2.setText(Html.fromHtml(convertHtmlTagIfNeed(descriptionContent2)));

Here's what it looks line:

line break after "les"

0 Answers
Related