2016-11-20 10 views
0

ich eine TableRow haben, die durch die Breite des Bildschirms erweitert und innerhalb dieser TableRow habe ich eine ListView deren layout_width ist auf match_parent, es gibt aber noch nicht durch die Breite des Bildschirms zu erweitern. Es funktionierte richtig, aber seit ich 2 Tasten in der nächsten TableRow das Problem aufgetreten ist aufgetreten. Ich habe layout_span Eigenschaft auf 2 gesetzt und funktioniert immer noch nicht. Hier ist meine xmlLayout füllt nicht Mutter

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

    <TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/saltnpepper"> 

     <TableRow 
     android:layout_weight="1" 
     android:gravity="center"> 

      <TextView 
      android:layout_height="200dp" 
      android:layout_width="match_parent" 
      android:background="#FF00FF" 
      android:layout_span="2"/> 
     </TableRow> 

     <TableRow 
     android:layout_weight="4" 
     android:layout_marginTop="5dp" 
     android:background="#FF00FF" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

      <ListView 
      android:id="@+id/list1" 
      android:layout_span="2" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="5dp" 
      android:layout_marginBottom="5dp"> 
      </ListView> 
     </TableRow> 

     <TableRow 
     android:layout_weight="1" 
     android:gravity="center" 
     android:layout_width="match_parent"> 

      <Button 
      android:id="@+id/btnAddToOrder" 
      android:text="Add To Order" 
      android:layout_height="wrap_content" 
      android:layout_width = "match_parent" 
      android:background="#FF00FF" /> 

      <Button 
      android:id="@+id/btnProceed" 
      android:text="Order Now" 
      android:layout_height="wrap_content" 
      android:layout_width = "match_parent"   
      android:background="#FF00FF" /> 

     </TableRow> 
    </TableLayout> 

Ich habe versucht, Hintergrundfarben ändern, damit ich bin sicher, dass das genaue Problem ist mit ListView nicht die gesamte Breite des Bildschirms während TableRow (mittlere) erweitert perfekt ist passend auf den Bildschirm

+0

Wo ist Ihr Listenelementlayout? – Rookie

Antwort

1

diesen Code Versuchen:

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

<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FFFF00" 
    android:layout_weight="3"> 

    <TableRow 
     android:layout_weight="1" 
     android:gravity="center"> 

     <TextView 
      android:layout_height="200dp" 
      android:layout_width="match_parent" 
      android:background="#FF00FF" 
      android:layout_span="4"/> 
    </TableRow> 

    <TableRow 
     android:layout_weight="2" 
     android:gravity="center"> 

     <RelativeLayout 
      android:layout_weight="1" 
      android:layout_marginTop="5dp" 
      android:background="#FF00FF" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ListView android:id="@+id/list1" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="5dp" 
       android:layout_marginBottom="5dp" 
       > 
      </ListView> 

     </RelativeLayout> 
    </TableRow> 




    <TableRow 
     android:gravity="center" 
     android:layout_width="match_parent"> 

     <Button android:id="@+id/btnAddToOrder" 
      android:text="Add To Order" 
      android:layout_height="wrap_content" 
      android:layout_width = "match_parent" 
      android:background="#FF00FF" /> 
     <Button android:id="@+id/btnProceed" 
      android:text="Order Now" 
      android:layout_height="wrap_content" 
      android:layout_width = "match_parent" 
      android:background="#FF00FF" /> 

    </TableRow> 

</TableLayout> 

Es zeigt Ausgabe wie Sie möchten.

+0

Danke! Es hat funktioniert: D..So legst du die Listenansicht in relatives Layout und Gewicht = 1, das ist, was fehlte .. ich nehme an .. – Samra

Verwandte Themen