【问题标题】:A wide vertical ListView inside a horizontal scrollview in AndroidAndroid中水平滚动视图内的宽垂直ListView
【发布时间】: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


    【解决方案1】:

    里面的 TextViews 加起来正好 2400dp,你给你的 listview 正好 2400dp 宽度,但我认为 listview 本身需要一些 dp,例如小滚动条来垂直滚动项目我会假设这是你的像素不见了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-27
      • 2013-07-18
      • 1970-01-01
      • 2015-01-27
      • 2011-01-03
      • 2014-12-09
      • 1970-01-01
      相关资源
      最近更新 更多