2012-10-02 116 views
2

我有一個多列行列表視圖,其中一行必須是一個列表視圖也有多行,但其中只有2個需要顯示,其餘顯示只在滾動。我在listview int layout文件中添加了一個帶有LinearLayout的ScrollView,並且我在java文件中添加了行的內容。 ScrollView似乎不太好。有沒有更好的方法來實現這一點? 這是我的佈局文件。列表視圖內的滾動查看

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/listLayout" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<ListView 
    android:id="@android:id/list" 
    android:layout_width="1px" 
    android:layout_height="1px" 
    android:layout_weight="1" 
    android:cacheColorHint="#00000000" 
    android:scrollbars="vertical" > 
</ListView> 

<RelativeLayout 
    android:id="@+id/listItem" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <ImageView 
     android:id="@+id/formImage" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="fitXY" /> 

    <include layout="@layout/vertical_list_item_title_area" /> 
</RelativeLayout> 


    <ScrollView 
    android:id="@+id/scrollView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:layout_weight="1"> 

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

    </LinearLayout> 
</ScrollView> 

<com.illumemobile.testapp.Classes.SCClasses.SCActivities.SCCustomActivities.SCCustomGallery 
    android:id="@+id/horizontallistview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:scaleType="fitXY" 
    android:spacing="33dip" /> 

回答

3

列表視圖的ScrollViews內部是一個非常非常糟糕的主意。這不僅會讓用戶感到困惑,而且系統在確定哪個View應該獲得觸摸事件時存在問題。

我會推薦重新考慮你的佈局。

+0

但這是在幾種情況下的要求 – usman

+0

這是一個非常非常糟糕的主意,如果在問題的主體上面的代碼塊是可滾動的,而整個頁面也是可滾動的? StackOverflow應該重新考慮它的UI佈局嗎? – Ivan

+0

你可以自由地做任何你想做的事,我只是知道這不是一個好主意。首先關閉滾動事件。你有沒有嘗試過使用鼠標滾輪拖放到堆棧溢出文章的底部,該文章有一堆長碼片段?這不是最好的體驗。實際上,堆棧會自動擴展其移動應用程序中這些塊的高度以避免此問題。其次,你有沒有嘗試在Stack上使用敘述者?它不存在。事實上,Windows Store在全頁面垂直滾動中使用水平列表啓動,並快速調整了設計。 –

2

我會建議製作一個ScrollView,然後在滾動視圖內製作一個LinearLayout。在LinearLayout中,你可以將更多的LinearLayout作爲一個或多個子項。我認爲這會接近你想要做的事情......我更喜歡使用ScrollViews和LinearLayouts,而不是試圖處理ListViews。根據我的經驗,LinearLayouts比ListView更加動態。 - 希望這可以幫助