2016-06-03 13 views
0

My current layout and below it, what I want isAndroid Tabellen-Layout, nicht in Gewicht

passt Wie man hier sehen kann, versuche ich mit Gewichten zu verwalten.

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout 
    android:id="@+id/dialog_table_results" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="20dp" 

    xmlns:android="http://schemas.android.com/apk/res/android"> 

<TableRow> 
    android:id="@+id/headerrow 

    > 


    <TextView 
     android:text="" 
     android:layout_weight="0.25"/> 

    <TextView 
     android:text="@string/choosing" 
     android:layout_weight="0.25"/> 

    <TextView 
     android:text="@string/matching" 
     android:layout_weight="0.25"/> 

    <TextView 
     android:text="@string/counting" 
     android:layout_weight="0.25"/> 

</TableRow> 

    <TableRow> 
     android:id="@+id/subheaderrow 
     > 


     <TextView 
      android:text="" 
      android:layout_weight="0.28" 
      /> 

     <TextView 
      android:text="@string/trueanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/falseanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/halftrueanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/trueanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/falseanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/halftrueanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/trueanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/falseanswer" 
      android:layout_weight="0.08"/> 

     <TextView 
      android:text="@string/halftrueanswer" 
      android:layout_weight="0.08"/> 


    </TableRow> 





</TableLayout> 

Jede Zeile hat 1 Gewicht.

Für die erste Reihe hat jede Spalte 0,25 Gewicht.

Die erste Spalte der ersten Zeile ist leer, wiederum muss sie 0,25 sein, um die erste Zeile auszurichten. Weil es nach diesen Zeilen mehr Zeilen geben wird.

Ich habe das Layout Spaltenattribut nur hier https://stackoverflow.com/a/10762446/6412889

Für die erste Reihe beschrieben, zwischen oder 0-3, für die zweite, 0 bis 10.

Ich löschte Gewicht, versuchte mit Gewichten aber nicht ändern

ich habe auch

android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

oder Spiel Elternteil gelöscht, links nur Tablelayout Breite h acht aber hat nicht funktioniert. Auch hinzugefügt

android:shrinkColumns="*" 
android:stretchColumns="*" 

aber es wurde schlechter.

https://stackoverflow.com/a/14941587/6412889 das hat auch nicht funktioniert. Es machte die obere Reihe gut, aber die zweite ist immer noch gleich. Auch oben ist nicht gut, die 4 Spalten müssen gleich sein.

Vielleicht wird die Verwendung von Listview besser?

Wenn ein Benutzer auf ein Symbol klickt, wird ein Popup-Menü angezeigt. Klickt der Nutzer zuerst darauf, wird ein Popup-Tabellayout angezeigt. Ich weiß nicht, ob Listview dafür geeignet sein kann. Mit Tischplatten wäre es wirklich einfach. Und ich brauche auch keinen Listenklick von Listview. Es ist nur zum Zeigen.

Antwort

0

Möchten Sie so etwas erreichen? :

<?xml version="1.0" encoding="utf-8"?> 
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:alignmentMode="alignBounds" 
    android:columnCount="9"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnSpan="3" 
     android:layout_columnWeight="1" 
     android:text="aaaaaa" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnSpan="3" 
     android:layout_columnWeight="1" 
     android:text="bbbbb" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnSpan="3" 
     android:layout_columnWeight="1" 
     android:text="ccccc" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="d" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="e" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="f" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="g" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="h" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="i" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="j" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_columnWeight="1" 
     android:text="k" /> 
</GridLayout> 
+0

wie kann ich dynamische reihen hinzufügen? – user6412889

+0

http://stackoverflow.com/a/14715333/3816621 – user3816621