【问题标题】:make ListView Scrollbar difference and more useful让 ListView Scrollbar 与众不同,更有用
【发布时间】:2012-09-19 12:54:33
【问题描述】:

我已经看到很多具有 ListView 的 Android 应用程序与我的 ListViews 存在一些差异。在他们的 ListView 滚动条中看到是这样的:

在上图中,当您滚动列表时,将显示滚动条,您可以触摸它并更轻松地滚动。

但在我的应用中是这样的:

这是我的布局 xml 代码:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingBottom="4dp"
        android:text="@string/do"
        android:textSize="16dp" />

    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/main_background"

        >
    </ListView>
</LinearLayout>

我用谷歌搜索了很多次,但我没有找到任何技巧。任何人都可以帮助我如何让我的卷轴像第一张图一样?

【问题讨论】:

    标签: android android-listview android-scrollbar


    【解决方案1】:

    您可以在列表视图中添加这些行。它对我有用。

        android:fastScrollEnabled="true"
        android:scrollbars="none
    

    【讨论】:

      【解决方案2】:

      在列表视图的属性中设置android:fastScrollEnabled="true"。 此外,如果您希望快速滚动拇指始终可见,请设置 android:fastScrollAlwaysVisible="true"

      然后,在您的列表视图的 xml 定义中,您将拥有如下内容:

      <ListView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:fastScrollAlwaysVisible="true"
          android:fastScrollEnabled="true" >
      </ListView>
      

      【讨论】:

      • @aTa 还添加 android:scrollbars="none" (如下所示)并查看它是否有效。而且最好把你的layout xml文件贴在这里,这样我们可以检查它来检测有问题的属性。
      • 感谢 uuuuuu yrajabi。你的代码工作正常。问题出在我的主题中:)
      【解决方案3】:
      Hi Use This attribute in your ListView which you declare in you layout file.
      
      android:scrollbars="none"
      

      【讨论】:

      • 你能再解释一下你想要什么吗?
      猜你喜欢
      • 2011-09-09
      • 1970-01-01
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-10
      • 2012-05-15
      • 1970-01-01
      相关资源
      最近更新 更多