0

J'ai suivi ce morceau de code écrit par Aby dans une autre question: https://stackoverflow.com/a/22682248/5915747ScrollView est la coupe de début du texte

Le début de mon texte est coupé sur le côté gauche de mon écran. Il me manque pas mal d'infos et je ne sais pas comment y remédier, j'ai essayé tout ce qui fonctionnait pour les autres mais ça n'a pas marché pour moi.

popup.xml

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/scrollviewtest" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
tools:context="com.info.PopupActivity" 
android:background="#f0f0f0" 
android:layout_alignParentLeft="true" 
android:layout_alignParentStart="true"> 

    <HorizontalScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" 
     android:id="@+id/rel_layout" 
     android:orientation="vertical"> 

     <TableLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/table_layout" 
      android:background="#80000000" 
      android:layout_centerHorizontal="true"> 

     </TableLayout> 

    </RelativeLayout> 

    </HorizontalScrollView> 

</ScrollView> 

méthode init:

public void init() { 

    View popupview = getLayoutInflater().inflate(R.layout.popup, null); 
    popupWindow = new PopupWindow(
      popupview, LinearLayout.LayoutParams.MATCH_PARENT, 
      LinearLayout.LayoutParams.MATCH_PARENT 
    ); 
    popupWindow.showAtLocation(popupview, Gravity.CENTER, 0, 0); 
    popup_shown[0] = true; 

    TableLayout tableLayout = (TableLayout) popupview.findViewById(R.id.table_layout); 

    TableRow row0 = new TableRow(this); 

    TextView text0 = new TextView(this); 
    text0.setText("Test Header1"); 
    row0.addView(text0); 

    TextView text1 = new TextView(this); 
    text1.setText("Test Header2"); 
    row0.addView(text1); 

    TextView text2 = new TextView(this); 
    text2.setText("Teset Header3"); 
    row0.addView(text2); 

    TextView text3 = new TextView(this); 
    text3.setText("Test Header4"); 
    row0.addView(text3); 

    TextView text4 = new TextView(this); 
    text4.setText("Test Header5"); 
    row0.addView(text4); 

    tableLayout.addView(row0); 

    for (int i = 0; i < 8; i++) { 
     TableRow tableRow = new TableRow(this); 
     TextView tv0 = new TextView(this); 
     tv0.setGravity(Gravity.CENTER); 
     tv0.setText("long test field 0"); 
     tableRow.addView(tv0); 

     TextView tv1 = new TextView(this); 
     tv1.setGravity(Gravity.CENTER); 
     tv1.setText("long test field 1"); 
     tableRow.addView(tv1); 

     TextView tv2 = new TextView(this); 
     tv2.setGravity(Gravity.CENTER); 
     tv2.setText("long test field 2"); 
     tableRow.addView(tv2); 

     TextView tv3 = new TextView(this); 
     tv3.setGravity(Gravity.CENTER); 
     tv3.setText("long test field 3"); 
     tableRow.addView(tv3); 

     TextView tv4 = new TextView(this); 
     tv4.setGravity(Gravity.CENTER); 
     tv4.setText("long test field 3"); 
     tableRow.addView(tv4); 


     tableLayout.addView(tableRow); 
    } 

} 

Plus les chaînes sont des vues de texte, plus il rogne loin, mais il est un scrollview horizontal, il devrait donc juste commencer au début de l'écran et ajouter une longueur à la fin, ce qui est défilement, non?

C'est ce qu'il finit par ressembler à des chaînes actuelles orientation verticale/portrait: Vertical View

C'est ce qu'il ressemble à horizontale, il semble fixer depuis mon écran est grand assez pour les données: Horizontal View

Si vous avez des questions, s'il vous plaît demander!

Résolu cela en ajoutant un rembourrage à la scrollview. Il semble que ce soit un bug Android commun.

+0

Peut-être ajouter un peu de rembourrage: D – Vucko

Répondre

0

Je ne sais pas que ça va marcher ou pas, mais essayez de supprimer

android: layout_gravity = "center"

ligne de mise en page relative

+0

Cela n'a pas résolu mon problème: / – aj21