2010-11-25 7 views
0

私はAndroidアプリケーションにLinearLayoutを持っています。Android GridViewは私のボタンを隠す

はちょうど2つのボタンでうまく働い - しかし、私はGridViewコントロールを追加したとき、それは今2つのボタンが非表示になります - 私は、GridViewコントロールの上または下

を入れた場合に関係なく、誰でも助けることはできますか?

<?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" /> 

答えて

0

私はこれを解決 - ルートレベルのLinearLayoutを水平の向きに設定されたためでした。

これを 'vertical'に変更し、2つのButton要素を 'horizo​​ntal'方向で独自のLinearLayoutにラップしました。ここ

はblockquotesは、XMLドキュメントのセクションを隠し続ける得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

あります。上記のXmlには、ルートレベルのLinearLayoutがなく、方向が 'vertical'に設定されています。 – KennetRunner

関連する問題