滚动视图中的滚动条只有在我开始滚动时才可见。 我怎么才能一直表现出来呢?


当前回答

设置这个就可以了。更改@drwable为自己的风格。

android:scrollbars="vertical"
            android:scrollbarAlwaysDrawVerticalTrack="true"
            android:fadeScrollbars="false"
            android:scrollbarThumbVertical="@drawable/scroll"`

其他回答

样式你的滚动条可见性,颜色和厚度像这样:

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/recycler_bg"

        <!--Show Scroll Bar-->
        android:fadeScrollbars="false"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbarFadeDuration="50000"

        <!--Scroll Bar thickness-->
        android:scrollbarSize="4dp"

        <!--Scroll Bar Color-->
        android:scrollbarThumbVertical="@color/colorSecondaryText"/>

希望能帮你节省时间。

使用awakenScrollBars()唤醒滚动条绘制。

不要忘记添加android:scrollbars="vertical"和android:fadeScrollbars="false",否则在某些情况下它根本不会显示。

这两条加起来对我很有用:

android:scrollbarFadeDuration="0"
android:scrollbarAlwaysDrawVerticalTrack="true"

到目前为止,最好的方法是使用android:fadeScrollbars="false"在xml中,这相当于ScrollView.setScrollbarFadingEnabled(false);在Java代码中。