如何始终显示滚动条
滚动视图中的滚动条仅在我开始滚动时才可见。 我怎样才能始终显示它?
The scrollbar in my scrollview is only visible when I start scrolling.
How can I always show it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
目前最好的方法是在 xml 中使用
android:fadeScrollbars="false"
,这相当于 Java 代码中的ScrollView.setScrollbarFadingEnabled(false);
。As of now the best way is to use
android:fadeScrollbars="false"
in xml which is equivalent toScrollView.setScrollbarFadingEnabled(false);
in java code.设置
android:scrollbarFadeDuration="0"
就可以了。Setting the
android:scrollbarFadeDuration="0"
will do the trick.有 4 种方法:
ScrollView.setScrollbarFadingEnabled(false);
android:fadeScrollbars="false"
myView. setScrollBarFadeDuration(0)
android:scrollbarFadeDuration="0"
就这么简单!
There are 4 ways:
ScrollView.setScrollbarFadingEnabled(false);
android:fadeScrollbars="false"
myView.setScrollBarFadeDuration(0)
android:scrollbarFadeDuration="0"
Simple as that!
不要忘记添加
android:scrollbars="vertical"
和android:fadeScrollbars="false"
,否则在某些情况下根本不会显示。Don't forget to add
android:scrollbars="vertical"
along withandroid:fadeScrollbars="false"
or it won't show at all in some cases.像这样设置滚动条可见性、颜色和厚度:
希望它有助于节省一些时间。
Style your scroll bar Visibility, Color and Thickness like this:
Hope it help save some time.
尝试一下,因为当我想对 TextView 执行此操作时,上述建议对我不起作用:
祝你好运。
Try this as the above suggestions didn't work for me when I wanted to do this for a TextView:
Good Luck.
简单又容易。将此属性添加到
ScrollBar
:或者您可以在 java:
或者在 kotlin< /a>:
Simple and easy. Add this attribute to the
ScrollBar
:Or you can do this in java:
Or in kotlin:
尝试使用
android:scrollbarAlwaysDrawVerticalTrack="true"
进行垂直设置。并尝试
android:scrollbarAlwaysDrawHorizontalTrack="true"
水平Try
android:scrollbarAlwaysDrawVerticalTrack="true"
for vertical.and Try
android:scrollbarAlwaysDrawHorizontalTrack="true"
for horizontal由于上述方法都不适合我,因此执行以下操作:
android:scrollbarDefaultDelayBeforeFade="500000"
Since neither of the above worked for me, here's what did:
android:scrollbarDefaultDelayBeforeFade="500000"
android:scrollbarFadeDuration="0"
有时在我退出应用程序并重新启动后不起作用。因此,我将gallery.setScrollbarFadingEnabled(false);
添加到活动中并且它起作用了!android:scrollbarFadeDuration="0"
sometimes does not work after I exit from the apps and start again. So I addgallery.setScrollbarFadingEnabled(false);
to the activity and it works!这两个一起为我工作:
These two together worked for me:
我也有同样的问题。酒吧的背景颜色相同。尝试:
I had the same problem. The bar had the same background color. Try:
setVertical* 有助于使垂直滚动条始终以编程方式可见
setVertical* helped to make vertical scrollbar always visible programmatically
设置这个就可以了。将 @drwable 更改为自己的样式。
Setting this will do the trick. Change the @drwable for own style.
使用wakeScrollBars()唤醒滚动条绘制。
use awakenScrollBars() awake scrollbar draw.