gpt4 book ai didi

android - 如何设置ListView的滚动条向右偏移

转载 作者:行者123 更新时间:2023-11-29 21:08:28 25 4
gpt4 key购买 nike

请在回答之前阅读,因为这可能不是您认为的问题

这是我的 ListView

<ListView
android:id="@+id/ist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/ca”
android:dividerHeight="@dimen/h1”
android:gravity="center" />

一切正常,除了滚动条显然有一个我没有设置的 paddingRightlayout_marginRight。滚动条本身——不是我从适配器填充的行项目。所以我看到的是滚动条从右边缘显示大约 10dp,而我的行的内容填满了屏幕的宽度。我想要的是滚动条完全显示在内容的右侧,这样它就不是沿 z 轴的视觉叠加。

最佳答案

尝试使用 scrollbarStyle。我发现 android:scrollbarStyle="outsideOverlay" 效果最好/看起来最好。

控制滚动条的样式和位置。

http://developer.android.com/reference/android/view/View.html#setScrollBarStyle(int)

public void setScrollBarStyle (int style)

Added in API level 1 Specify the style of the scrollbars. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding, then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.

Related XML Attributes android:scrollbarStyle Parameters style the style of the scrollbars. Should be one of SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_INSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET. See Also SCROLLBARS_INSIDE_OVERLAY SCROLLBARS_INSIDE_INSET SCROLLBARS_OUTSIDE_OVERLAY SCROLLBARS_OUTSIDE_INSET

关于android - 如何设置ListView的滚动条向右偏移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23714589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com