2011-11-04 2 views
0

J'ai actuellement un tabview avec un listview à l'intérieur. J'ai seulement trois articles dans le listview et pour une raison quelconque, il y a un tas d'espace blanc en haut. Autrement dit, le premier élément ne commence pas en haut mais plutôt au milieu. Des idées? En outre, je pense que j'utilise la mauvaise mise en page. quoi de mieux qu'un listview si j'ai seulement besoin d'afficher trois éléments? Merci.Android- espace vide en haut de la liste affichage

code:

// Data to put in the ListAdapter 
    private String[] sdrPlaylistNames = new String[]{ "More Playlists...","Dubstep", "House"}; 


    Intent playbackServiceIntentDUB, playbackServiceIntentHOUSE; 

    //alert dialog 
    AlertDialog.Builder builder; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.playlists_layout); 
     //fill the screen with the list adapter 
     playlistFillData(); 

     playbackServiceIntentDUB = new Intent(this, DUBAudioService.class); 
     playbackServiceIntentHOUSE = new Intent(this, HOUSEAudioService.class);  

    } 

    public void playlistFillData() { 
     //create and set up the Array adapter for the list view 
     ArrayAdapter<?> sdrListAdapter = new ArrayAdapter<Object>(this, R.layout.list_item, sdrPlaylistNames); 
     setListAdapter(sdrListAdapter); 
    } 

XML:

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

    <ListView 
     android:id="@id/android:list" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/selectP" android:stackFromBottom="false"> 
    </ListView> 

    <TextView 
     android:id="@id/android:empty" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20dp" /> 

    <TextView 
     android:id="@+id/selectP" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:gravity="center" 
     android:text="Select A Playlist Above" 
     android:textColor="#FF3300" 
     android:textSize="22dp" 
     android:textStyle="bold" > 
    </TextView> 

</RelativeLayout> 
+0

essayer de faire la largeur de la disposition relative et hauteur fill_parent et ajoutez requestWindowFeature (Window.FEATURE_NO_TITLE); dans votre méthode onCreate(). –

Répondre

0

Oh, j'ai raté votre vrai problème dans ma réponse précédente.

simplement mis android:layout_alignParentTop="true" à votre liste comme

<ListView 
     android:id="@id/android:list" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_above="@+id/selectP" android:stackFromBottom="false"> 
    </ListView> 

espoir cette fois, je suis clair ..

0

Définissez votre point de vue de la liste pour AlignParentTop = true

Questions connexes