2017-01-28 1 views
1

Ich habe gesucht, aber nach einer Weile kann ich die Lösung nicht finden. Ich habe drei Textviews in einer horizontalen Linearlayout, aber der Text ist geht nicht in mehreren Zeilen aber wie folgt aussehen:Weitere Textansichten in mehreren Zeilen

enter image description here

Ich fand, dass in Android eine Komponente Flow ist, aber ich kann nicht etwas Ähnliches finden für Xamarin. Haben Sie irgendwelche Vorschläge oder irgendeinen nativen Java-Code, der für Xamarin funktioniert? Danke im Voraus. Hier

ist der Code:

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#000" 
     android:textSize="11sp" 
     android:text="dora sareva" 
     android:textStyle="bold"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#8289A6" 
     android:textSize="11sp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:text="reacted to your recording reacted to your recording"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#000" 
     android:textSize="11sp" 
     android:textStyle="bold" 
     android:text="First reading practice"/> 
</LinearLayout> 
+0

Versuchte 'android: orientation =" vertical "'? –

+0

ja und sie sind in separaten vertikalen Linien, die nicht das ist, was ich brauche, muss ich einen Blick wie der gleiche Satz – Merian

+0

bekommen überprüfen Sie dies https://github.com/DefinitelyBound/xamarin-android/tree/master/android -flowlayout Ich weiß nicht viel über Xmarin. aber es könnte dir helfen. –

Antwort

2

In unserem Java-Code fügen Sie diese:

final TextView tv = (TextView) findViewById(R.id.textView); 
     tv.setText(Html.fromHtml(getString(R.string.text_sample))); 

In Ihrem String.xml Datei hinzufügen, um dieses

<string name="text_sample"><![CDATA[ dora sareva <font color=\'#8289A6\'>reacted to your recording</font>reacted to your recording First reading practice]]></string> 

Und dieses Add nur in Ihrer XML-Datei:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:lines="1" 
     android:maxLines="1" 
     android:id="@+id/textView" 
     android:text="@string/text_sample" 
     android:textColor="#000" 
     android:textSize="11sp" 
     android:textStyle="bold" /> 

</LinearLayout> 
+0

Danke, das war's – Merian

Verwandte Themen