2017-07-07 1 views
0

Ich habe ein Layout mit einer TextView, die etwas Text von einem BBDD empfängt. Wenn ich eine lange Zeichenfolge in das Layout schreibe, wird alles korrekt angezeigt. Wenn derselbe Text von texview.settext("sodjsdoifjsodfsd");Text in TextView ändern zeigt nicht mehr als drei Zeilen, aber auf dem Layout wird es richtig angezeigt

geschrieben wird, sehe ich, dass die TextView nur die Zeilen dieser Zeichenfolge anzeigen kann.

Ich meine, es kann seine Dimension auf dem Layout ändern und ich kann es richtig sehen, mit vier oder mehr Zeilen, wenn es notwendig ist, aber wenn ich den Text mit einer langen Zeichenfolge ändern (als die Zeichenfolge im Layout) Ich sehe nur drei Zeilen dieses Textes. Ich habe das gleiche Problem mit dem Text der Tasten.

ich ein Bild setzen, hoffen, es hilft:

enter image description here

Hier ist mein Layout-Code:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

<ScrollView 
    android:layout_width="match_parent" 
    android:fillViewport="true" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/HeaderTextView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentStart="true" 
      android:text="Which ability of metal AM improves the osseointegrationdddddddddddddddddddddddddddddddddddddddddddddddd capability and reduces surgical implants rejection rates?" 
      android:textSize="20dp" /> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentStart="true" 
      android:layout_below="@+id/HeaderTextView" 
      android:paddingEnd="10dp" 
      android:paddingStart="10dp" 
      android:paddingTop="20dp"> 


      <TableRow 
       android:id="@+id/tableRow2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="2dp"> 

       <Button 
        android:id="@+id/answer1" 
        android:layout_width="0dip" 
        android:layout_height="fill_parent" 
        android:layout_gravity="center" 
        android:layout_marginBottom="2dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="2dp" 
        android:layout_weight="1" 
        android:paddingLeft="20dp" 
        android:paddingRight="20dp" 
        android:background="@color/primary" 
        android:textColor="@color/accent" 
        android:text="It doesn't need supports and allows to build in several levels" 
        android:textSize="10dp" /> 

       <Button 
        android:id="@+id/answer2" 
        android:layout_width="0dip" 
        android:layout_height="fill_parent" 
        android:layout_gravity="center" 
        android:layout_marginBottom="2dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="2dp" 
        android:layout_weight="1" 
        android:paddingLeft="20dp" 
        android:paddingRight="20dp" 
        android:background="@color/primary" 
        android:textColor="@color/accent" 
        android:text="ANSWER 2" 
        android:textSize="10dp" /> 
      </TableRow> 

      <TableRow 
       android:id="@+id/tableRow3" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="2dp"> 

       <Button 
        android:id="@+id/answer3" 
        android:layout_width="0dip" 
        android:layout_height="fill_parent" 
        android:layout_gravity="center" 
        android:layout_marginBottom="2dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="2dp" 
        android:layout_weight="1" 
        android:paddingLeft="20dp" 
        android:paddingRight="20dp" 
        android:background="@color/primary" 
        android:textColor="@color/accent" 
        android:text="ANSWER 3" 
        android:textSize="10dp" /> 

       <Button 
        android:id="@+id/answer4" 
        android:layout_width="0dip" 
        android:layout_height="fill_parent" 
        android:layout_gravity="center" 
        android:layout_marginBottom="2dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="2dp" 
        android:layout_weight="1" 
        android:paddingLeft="20dp" 
        android:background="@color/primary" 
        android:textColor="@color/accent" 
        android:paddingRight="20dp" 
        android:text="ANSWER 4" 
        android:textSize="10dp" /> 
      </TableRow> 

      <TableRow 
       android:id="@+id/tableRow4" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="2dp"> 

       <TextView 
        android:id="@+id/HeaderTextView2" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="SEE ACRONYM BUTTON FOR MORE INFORMATION" /> 
      </TableRow> 
     </TableLayout> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:paddingStart="10dp"> 

      <TableRow 
       android:id="@+id/tableRow6" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="2dp"> 

       <Button 
        android:id="@+id/acronism" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:padding="5dp" 

        android:background="@color/primary" 
        android:textColor="@color/accent" 
        android:text="ACRONYM" 
        android:textSize="20dp" /> 

       <Button 
        android:id="@+id/explanation" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:padding="5dp" 

        android:background="@color/primary" 
        android:textColor="@color/accent" 
        android:layout_marginBottom="2dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="2dp" 
        android:text="Explanation" 
        android:textSize="20dp" /> 
      </TableRow> 
     </TableLayout> 

     <TextView 
      android:id="@+id/PointsTextView" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:padding="5dp" 
      android:text="POINTS: " 
      android:textAlignment="textEnd" /> 
    </RelativeLayout> 
</ScrollView> 

Und die Klasse Code, wo ich den Text ändern:

header4questions.setText(listQuestions.get(questionPosition)); 
answer1.setText(listAnswers.get(questionPosition * 4)); 
answer2.setText(listAnswers.get((questionPosition * 4) + 1)); 
answer3.setText(listAnswers.get((questionPosition * 4) + 2)); 
answer4.setText(listAnswers.get((questionPosition * 4) + 3)); 

Ich weiß nicht, warum es perfekt auf dem Layout funktioniert, aber nicht mit dem Android-Code.

Kann mir jemand helfen?

Vielen Dank!

Antwort

0

Es ist ein Attribut namens maxLines es wie diese, die versuchen

android:maxLines="2" 

geht.

+0

Ich versuche, bitte warten :) – Imrik

+0

es funktioniert nicht, es tut das gleiche. – Imrik

+0

können Sie einen Screenshot von dem, was passiert, teilen? –

Verwandte Themen