【问题标题】:Android ListView ScrollbarAndroid ListView 滚动条
【发布时间】:2011-05-17 16:30:04
【问题描述】:

我创建了一个列表视图。我需要增加垂直滚动条的宽度。我改变了 android:scrollbarSize。但它不起作用。还想减少滚动条拇指的长度。是否可行。请帮我。

<LinearLayout android:id="@+id/LinearLayout01" 
 android:layout_width="fill_parent" android:layout_height="fill_parent" 
 xmlns:android="http://schemas.android.com/apk/res/android">

<ListView 
 android:id="@+id/list_view"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:scrollbars="vertical"
 android:scrollbarAlwaysDrawVerticalTrack="true"
 android:scrollX="0px"
 android:scrollY="0px"
 android:background="#515151"
 android:layout_weight="1"
 android:scrollbarStyle="outsideOverlay"
 android:divider="#FFF"
 android:fadeScrollbars="false"
 android:scrollbarSize="20dip"/>

 </LinearLayout>

【问题讨论】:

  • 你能发布你的布局文件吗?
  • 将布局放入代码中...请检查一下
  • 尝试设置android:layout_width="wrap_content"
  • 我不能使用 wrap_content。因为我在对话框中使用列表视图,并且 list_view 应该填充对话框。
  • 有解决方案吗?请在这里发帖帮助我。

标签: android listview scrollbar


【解决方案1】:

您的滚动条将缩放到您为android:scrollbarTrackHorizontalandroid:scrollbarTrackVertical 指定的资源的宽度/高度。

这似乎是我现在能想到的唯一方法,我不会再胡思乱想了;)

因此,如果您想要一个 8 像素宽的水平轨道和一个 12 像素高的垂直轨道。为水平轨道创建一个 8px 宽的 PNG。为水平轨道创建一个 12px 高的 PNG。 android:scrollbarThumbHorizontalandroid:scrollbarThumbHorizontal 的九个补丁将在这些图像内自动缩放。

<item name="android:scrollbarTrackHorizontal">@drawable/png_12px_high</item>
<item name="android:scrollbarTrackVertical">@drawable/png_8px_wide</item>

【讨论】:

    【解决方案2】:

    我问了同样的问题,但没有得到任何答案:android ignores scrollbarsize

    然后,打开了一个问题,但关闭了它,说明“按预期工作”: http://code.google.com/p/android/issues/detail?id=7711&can=1&q=scrollbar%20width&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

    到目前为止,我还没有看到解决方案,虽然我还没有研究那么多。如果您找到任何解决方案,请更新此问题。

    【讨论】:

      猜你喜欢
      • 2011-03-07
      • 2023-03-28
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-17
      • 2014-12-15
      • 1970-01-01
      相关资源
      最近更新 更多