在我的 Activity 页面中,有一个布局在顶部(listview1)包含一个 ListView ,在 ListView 1下方,有一个textrview,在这个测试 View 下方,放置了第二个 ListView 。我想滚动整个布局。
下面是示例代码
<ScrollView
android:id="@+id/scrol1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/linearLayout1"
android:layout_marginTop="15dp" android:scrollbars="vertical" android:isScrollContainer="true">
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/linearLayout1"
android:layout_marginTop="15dp" >
<ListView
android:id="@+id/lstMore"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:divider="@null"
android:fadingEdge="none"
android:footerDividersEnabled="false" android:dividerHeight="0dp" android:cacheColorHint="#00000000">
</ListView>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Learn More"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black"
android:textStyle="bold" android:layout_below="@id/lstMore"/>
<ListView
android:id="@+id/lstMoreBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadingEdge="none" android:layout_below="@id/textView2" android:divider="@null" android:dividerHeight="0dp" android:cacheColorHint="#00000000">
</ListView>
</RelativeLayout>
</ScrollView>
最佳答案
根据我的经验,在一个 ScrollView 中不可能有多个 ListView。您尝试将两个可滚动小部件放置在另一个可滚动小部件中。
您应该做的是在您的列表适配器中扩展不同的布局,并拥有一个没有 ScrollView 的 ListView。
关于android - 如何在 android 中滚动包含 2 个 ListView 和一个 TextView 的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8832391/