Was ichWarum Zeichen/schneidet den Text in TextView wenn MaxLines = 1?
Ich habe ein Textview, die eine URL zeigt mit "https: //" Präfix:
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="test2"
android:maxLines="1"
android:ellipsize="marquee"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/primary_text"
android:id="@+id/txvNomEntornIversio" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="https://test2.sdasasdasdfasdfasdffasdfasdfasdf.sdffd"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="10dp"
android:textSize="13sp"
android:textStyle="italic"
android:id="@+id/txvUrlEntorn"/>
</LinearLayout>
Was ist das Problem?
Das Ergebnis in Android Studio-Vorschau und in der Vorrichtung nach dem Code auszuführen war:
Wenn vorherigen Code ausführen:
Wenn ich die "/" Symbole entfernen Wenn ich das Symbol in eine andere Position bewege:
WAS ICH
NEED Ich brauche die Vorsilbe für "https: //" mit maximalen Buchstaben den verfügbaren Raum zu passen.
WAS habe ich versucht,
ich read documentation (setEllipsize Block) versucht und in Stackoverflow suchen, die mit diesem Symbol für einige Referenz gesucht und nichts gefunden. Ich habe auch versucht, die Symbole ohne Wirkung zu scape.
Wer weiß, warum es auftritt und mir helfen kann? Danke im Voraus!
AKTUALISIERT LAYOUT
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/icon_unchecked"
android:layout_marginRight="10dp"
android:id="@+id/txvIconChecked"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="test2"
android:maxLines="1"
android:ellipsize="marquee"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/primary_text"
android:id="@+id/txvNomEntornIversio" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="https://mydomain.asdfasdasdfasdfasdffasdfasdfasdf.cat"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="10dp"
android:textSize="13sp"
android:textStyle="italic"
android:id="@+id/txvUrlEntorn"/>
</LinearLayout>
</LinearLayout>
UPDATE 2
Dank Teiky haben wir festgestellt, dass dieses Problem nur in Versionen auftritt, die niedriger als API 23 sind. Es könnte ein Fehler sein?
Die Option (veraltet) Android: SingleLine = "true" scheint in allen Versionen korrekt zu funktionieren! Stattdessen wird die neue Option android: MaxLines mit Android: ellipsize funktioniert nur für 23 ...
Im Moment die praktikabelste Option scheint deprecated Single zu ignorieren ...
LÖSUNG FÜR MICH
Schließlich, wie ich in der letzten Aktualisierung sagte, war meine Lösung, android weiter zu verwenden: SingleLine = True, auch wenn es als veraltet markiert ist.
Teikyo Sekunden, er versucht, einen dipsositiu Android 4.4.4 und hat gut funktioniert MaxLines ellipsize mit ... und ich, ein Gerät Lollipop schneide ich immer noch den Text, das Symbol zu finden/...
Set in Reaktion Teikyo so gut wie es mir geholfen hat, das Problem weiter zu untersuchen. Danke Ihnen allen für Ihre Hilfe!
fügen Sie ein extra/in Ihre Zeile: zB 'https: ///' Das erste/in der // ist ein escaping Zeichen –
Dank Jonathan, habe ich versucht: "https: ///" mit dem gleichen Ergebnis. .. Auch versucht "https: \/\ /" aber keine Wirkung ... – jcasadellaoller