2012-10-02 84 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更加动态。 - 希望这可以帮助