【发布时间】:2011-06-21 14:26:01
【问题描述】:
我需要在 android 中实现这个布局。视图必须有两个共享 30-70% 屏幕空间的列表视图。 右侧的列表必须是水平可滚动且垂直的...左侧的列表必须只能在垂直方向上滚动...并且当任一列表项(记录)必须位于同一行时列表向上/向下滚动。我尝试以这种方式实现相同的方法,它工作正常,但滚动时不够平滑......而且大多数时候屏幕变黑......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="horizontal">
<ListView android:id="@+id\lV1" android:layout_width="100dp"
android:layout_height="wrap_content" />
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@+id/lV2" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>
请注意,整个布局需要显示在选项卡视图中。 我把布局改成这个了,还是没有好结果
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_width="fill_parent" android:fillViewport="true"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="fill_parent" >
<ListView android:id="@+id/lV1" android:layout_width="100px"
android:layout_height="wrap_content" android:background="@color/white"
android:fadingEdge="vertical" android:cacheColorHint="#00000000"
android:fastScrollEnabled="true" />
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="@id/listView1">
<ListView android:id="@+id/lV2" android:layout_width="wrap_content"
android:fastScrollEnabled="true" android:layout_height="wrap_content"
android:background="@color/white" android:cacheColorHint="#00000000"
android:layout_toRightOf="@id/lV1" />
</HorizontalScrollView>
</RelativeLayout>
</ScrollView>
【问题讨论】:
-
我不确定我们是否可以在 HorizontalScrollView 中实现 ListView。它会为您水平滚动吗?
-
@khotmanish..是的,它确实有效......但有点慢
标签: android listview android-layout