2011-07-01 39 views
0

我有以下XML文件通過列表視圖進行填充。我無法滾動。請告知:Android:ScrollView不會滾動

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:orientation="vertical" 
android:id="@+id/BigLayout" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" 
    android:scrollbars="vertical"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:id="@+id/myMainLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <com.google.ads.AdView android:id="@+id/adViewer" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      ads:adUnitId="xxxxxxxxxxxxxx" 
      ads:adSize="BANNER" 
      ads:loadAdOnCreate="true"/> 
     <TextView 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:text="RandomDrunkQuotes.com" 
      android:id="@+id/lblTitle" 
      android:textSize="16px" 
      android:padding="5px" 
      android:textStyle="bold" 
      android:gravity="center_horizontal"/> 

     <!-- List Divider --> 
     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dip" 
      android:background="?android:attr/listDivider" /> 
     <!-- ListView (grid_items) --> 
     <ListView 
      android:id="@+id/listview" 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent"> 
     </ListView>    

    </LinearLayout> 

</ScrollView> 

</LinearLayout> 
+2

是否有特殊原因需要使用ScrollView?如果子視圖佔用比屏幕更多的空間,LinearLayouts固有地具有滾動功能。 – kibibyte

+0

你試圖用這種佈局完成什麼樣的行爲?你不應該把一個ListView放在一個ScrollView中 –

+1

只需要記住,ScrollView無法在垂直方向工作,並且有一個單獨的Horizo​​ntalScrollView。 – Vlad

回答

1

@GiantMarshmallow解決了它。

在移除滾動視圖和添加

android:fillViewport="true" 
android:scrollbars="vertical" 

到的LinearLayout固定我的問題母體。非常感謝大家的意見。

0

scrollView中的ListView是一個壞主意。儘量不要使用可聚焦的視圖。