【发布时间】:2014-11-05 09:57:41
【问题描述】:
我的 Android 应用中有一个垂直列表视图。
它的样式看起来像一个带有列的表格,即每个列表视图项模板在水平线性布局内都有多个文本视图。每个文本视图都有一个宽度,例如12个textview,每个200dp表示listview的宽度需要2400dp。
此列表视图需要垂直滚动,这很好,因为这是列表视图的内置功能。但是,由于列表视图的宽度很大,我也需要它来水平滚动(因为我不想在文本视图上使用权重并挤压以适应屏幕宽度)。
我想将列表视图放在水平滚动视图中。然后在listview上设置宽度为2400dp,水平scollview宽度为match_parent。
但是,滚动视图似乎没有延伸到足以显示列表视图的整个宽度。它水平滚动但还不够。这种方法哪里出错了?
在页面中:
<HorizontalScrollView
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:layout_height="match_parent"
android:layout_width="2400dp"/>
</HorizontalScrollView>
列表视图项
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
<TextView
android:text="Long text here..."
android:layout_width="200dp"
android:layout_height="match_parent"/>
</LinearLayout>
【问题讨论】:
标签: android listview scroll xamarin