2015-04-08 2 views
0

Je développe un jeu et ai besoin d'un popup pour les règles. J'écris le texte dans le fichier string.xml et l'affiche dans une vue de texte dans un Scrollview, mais tout le texte ne s'affiche pas. Seules les dernières lignes du texte s'affichent. Aidez-moi, s'il vous plaît!!Dans Android Textview dans un Scrollview, ne pas afficher tout le texte (qu'il obtient de strings.xml)

Voici la mise en page pop-up code xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" android:layout_height="match_parent" 
android:background="@drawable/dialogbg1" 
android:gravity="center" 
android:id="@+id/howto" 
android:orientation="vertical"> 

<ScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/scrollView" 
    android:layout_gravity="right" 
    android:layout_weight="1" 
    android:nestedScrollingEnabled="true"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/rule" 
     android:layout_gravity="center" 
     android:textColor="#fffff7f4" 
     android:id="@+id/rules" 
     android:textStyle="italic" 
     android:outlineProvider="paddedBounds" /> 
</ScrollView> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/done" 
    android:id="@+id/done" 
    android:layout_marginTop="5dp" 
    android:layout_weight="1" 
    android:textColor="#fffff7f4" 
    android:background="@drawable/buttbg1" 
    android:clickable="true"/> 

et la variable "règle" dans le fichier strings.xml

<string name="rule">Rules to play Mancala!!!\n\nMancala is an ancient family of board games, and there are numerous variants.\n 
    This is a version of the basic game, known as two-rank Mancala and also known as Kalah.\n 
    1.The Mancala board is made up of two rows of six holes, or pits, each.\n\n 
    2.Four playing pieces are placed in each of the 12 holes.\n\n 
    3.Each player has a store to the right side of the Mancala board.\n\n 
    4.The game begins with one player picking up all of the pieces in any one of the holes on his side.\n\n 
    5.Moving counter clockwise, the player deposits one of the stones in each hole until the stones run out.\n\n 
    6.If you run into your own store, deposit one piece in it. If you run into your opponent\'s store, skip it.\n\n 
    7.If the last piece you drop is in your own store, you get a free turn.\n\n 
    8.If the last piece you drop is in an empty hole on your side, you capture that piece and any pieces in the hole directly opposite.\n\n 
    9.Always place all captured pieces in your store.\n\n 
    10.The game ends when all six spaces on one side of the Mancala board are empty.\n\n 
    11.The player who still has pieces on his side of the board when the game ends captures all of those pieces.\n\n 
    12.Count all the pieces in each store. The winner is the player with the most pieces.</string> 

Je ne suis pas en mesure de comprendre pourquoi tout le texte ne s'affiche pas. Seul le texte de 4 s'affiche. Si je change la disposition de la mise en page, alors il est affiché à partir de 3. S'il vous plaît aidez-moi !!!

+0

montrer votre écran de sortie. –

Répondre

1

Déposez votre ligne android: layout_gravity = "center" from TextView.

+0

cela n'a pas fonctionné trop – Aparna

+0

Il est étrange. Êtes-vous sûr que vous avez supprimé 'android: layout_gravity =" center "' de TextView, pas de ScrollView? Par ailleurs, supprimer 'android : layout_weight = "1" 'de votre bouton – Ircover

+0

Oui cela a fonctionné merci beaucoup !!! – Aparna

0

Ajoutez android:maxLines="50" dans votre balise <TextView />. Cela fera de votre TextView un maximum de 50 lignes.

+0

cela n'a pas fonctionné :( – Aparna

0

l'intérieur de votre TextView Tag Utilisation:

android:layout_gravity="top"