2010-11-25 8 views
0

Ich habe ein LinearLayout in meiner Android-Anwendung.Android GridView verbirgt meine Tasten

gut funktioniert mit nur zwei Tasten - aber wenn ich die Gridview hinzugefügt, es versteckt sich nun die beiden Buttons - unabhängig davon, ob ich über oder unter dem Gridview

legte sie

Kann jemand helfen?

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

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/gridview" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:numColumns="4" 
android:verticalSpacing="10dp" 
android:horizontalSpacing="10dp" 
android:stretchMode="columnWidth" 
android:gravity="center"/> 

<Button android:layout_weight="1" 
android:layout_height="wrap_content" 
android:layout_marginTop="5px" 
android:layout_width="fill_parent" 
android:text="@string/week" /> 
<Button android:layout_weight="1" 
android:layout_marginTop="5px" 
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:text="@string/day" /> 

Antwort

0

I gelöst dies - es war, da die Wurzelebene Linearlayout mit einer Orientierung von horizontal gesetzt wurde.

Ich änderte dies zu "vertikal" und wickelte dann die zwei Button-Elemente in ihrem eigenen LinearLayout mit "horizontaler" Ausrichtung - alles funktioniert so, wie ich es jetzt brauchte.

Hier ist die resultierende XML-

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#ffffff"> 

     <Button android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5px" 
      android:layout_width="fill_parent" 
      android:text="@string/week" /> 
     <Button android:layout_weight="1" 
      android:layout_marginTop="5px" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:text="@string/day" /> 
</LinearLayout> 

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:numColumns="4" 
    android:verticalSpacing="10dp" 
    android:horizontalSpacing="10dp" 
    android:stretchMode="columnWidth" 
    android:gravity="center"/> 

+0

Die Blockzitate halten Abschnitte des XML-Dokuments versteckt. Das obige Xml hat ein Root-Level LinearLayout mit einer auf 'vertical' gesetzten Ausrichtung. – KennetRunner