2014-04-18 50 views
0

我在LinearLayout中創建了一個gridview和listview。顯示的數據是動態的。 gridview填充屏幕高度的80%,listview只有屏幕高度的20%,並且其中的項目是可滾動的,但由於屏幕高度的可用性,listview一次只顯示2個項目。ScrollView中的GridView和ListView

現在我想要父項的listview和gridview是可滾動的,但是gridview和listview不是這樣的,列表視圖一次可以顯示2個以上的項目。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:orientation="vertical" > 


    <include layout="@layout/app_headerview_imageview_textview" /> 

    <GridView 
     android:id="@+id/gridView" 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:listSelector="@null" 
     android:numColumns="3" 
     android:layout_weight="1" > 
    </GridView> 

    <LinearLayout 
     android:id="@+id/linearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#112F51" 
     android:orientation="horizontal" 
     android:padding="20dip" > 

     <Button 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/diagnose_button_selector" 
      android:text="Auto Diagnose" 
      android:textColor="#ffffff" 
      android:textSize="@dimen/small_text_size" 
      android:padding="@dimen/padding_medium"/> 

     <View 
      android:layout_width="0dip" 
      android:layout_height="1dip" 
      android:layout_weight=".2" /> 

     <Button 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/diagnose_button_selector" 
      android:text="Diagnose Now" 
       android:textColor="#ffffff" 
      android:textSize="@dimen/small_text_size" 
      android:padding="@dimen/padding_medium" /> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" > 
    </ListView> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#E6E6E6" 
    android:orientation="vertical" > 

    <include layout="@layout/bottom_action_bar" /> 
</LinearLayout> 

+0

金額上發表您的佈局'* .xml'文件 –

回答

1
  1. 一個scollview應該只有一個直接子

  2. 你不應該使用帶有一個ListView滾動型,因爲ListView控件 需要其自身的垂直滾動的照顧。最重要的是,這樣做 擊敗了ListView中所有重要的優化處理 大列表,因爲它有效地強制ListView顯示 其項目的整個列表來填充由 ScrollView提供的無限容器。

  3. 如果你想有更多的列表視圖中可在屏幕上,給事實的GridView也滾動,你應該讓他們採取了類似的使用重量屬性爲LinearLayout中的兩個孩子空間的屏幕

+0

現在我想讓父母滾動包含GridView和列表視圖。任何建議 – User10001