2017-06-08 4 views
1

Ich mache eine Listenansicht in Android, und meine Listview füllt nicht den gesamten Bildschirm. Es hat noch ein wenig Platz unterhalb der Listenansicht (wahrscheinlich, weil ich nicht genug Elemente habe, um den Bildschirm zu füllen). Ich habe online nach vielen Lösungen gesucht, aber keine scheint in der Lage zu sein, dieses Problem zu lösen.Wie kann ich zulassen, dass mein ListView den gesamten Bildschirm in Android ausfüllt?

Hier ist mein Layout:

<?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" 
    tools:context="com.ListActivity"> 

<ListView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id = "@+id/customListview"> 

</ListView> 


</LinearLayout> 

Hier mein item_layout.xml ist:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id= "@+id/ItemNameSales" 
     android:layout_alignParentLeft="true" 
     android:text="Item Name" 
     android:textAppearance="?android:attr/textAppearanceLarge"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id= "@+id/ItemNameQty" 
     android:layout_alignParentRight="true" 
     android:text="Item Quantity" 
     android:textAppearance="?android:attr/textAppearanceLarge"/> 

</RelativeLayout> 
+0

zeigen Sie Ihren Adapter Artikel xml Ansicht pls –

+0

@VladislavShcherbakov getan! Bitte sehen Sie sich um! :) – Shells

+0

und R.layout.item_layout xml pls –

Antwort

0

Sie es dinamically sich ändern müssen den intire Bildschirm zu passen !!!

list.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, CalculateHowYouNeedToFitScreen)); 
+0

FILL_PARENT ist veraltet! –

+0

@MilosLulic ändern Sie es –

+0

@RodrigoGontijo Was bedeuten Sie berechnen, wie Sie Bildschirm anpassen müssen? – Shells

0

Kann ich Sie etwas fragen? Warum textView (id = itemNameSells) Höhe ist Match_parent?

Wird die zweite textView im Modell angezeigt?

Sorry, aber ich kann nicht Kommentar von Android-App hinzufügen, wenn ich nicht beantworten ...

0

Ihre Listview ist bereits gesamten Bildschirm Problem füllen ist, dass Sie nicht haben enaf Objekte in der Liste. Eine andere Sache, die Sie tun shoud ist Inhaber Klasse erstellen Listview lose Liste prevant kann order.You dinamicly widht und Höhe des Elements ändern Bildschirm zu füllen, aber das ist schlechte Praktiken bei der Codierung

View itemView = convertView; 
    ViewHolder holder; 

    if (itemView == null) { 

    itemView = getLayoutInflater().inflate(R.layout.YOURVIEW,parent,false); 
    holder = new ViewHolder(); 
    itemView.setTag(holder); 
    }else { 
    holder = (ViewHolder) itemView.getTag(); 
    } 
    SalesItemInformationLV iteminfo = item.get(position); 

    holder.something = (TextView)itemView.findViewById(R.id.ItemNameSales); 

    public class ViewHolder{ 

     public TextView something; 
    } 
Verwandte Themen