【问题标题】:vertical scroll bar not visible inside horizontal scroll bar android垂直滚动条在水平滚动条android内部不可见
【发布时间】:2013-06-18 16:06:20
【问题描述】:

我在水平滚动条中有一个垂直滚动条。 仅当我一直水平滚动到右侧时,垂直滚动条才可见。但我希望它始终可见。

我该怎么做?有什么帮助吗?提前谢谢

我的 xml 看起来像这样

<HorizontalScrollView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/gridTitle"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="18dp"
    android:layout_marginBottom="5dp"
    android:fadeScrollbars="false" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginBottom="13dp">

        <!-- This Table Layout is header followed by the table itself-->
        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:stretchColumns="*" >

            <TableRow 
                android:id="@+id/tableHeader"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </TableRow>

        </TableLayout>

       <ScrollView 
                android:id="@+id/verticalScroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fadeScrollbars="false">

                <TableLayout
                    android:id="@+id/layout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="12dp"
                    android:stretchColumns="*" >
                </TableLayout>

        </ScrollView> 

    </LinearLayout>

</HorizontalScrollView>

已编辑:

问题是,垂直滚动条在屏幕之外(如果我有很多表格列),所以我只能在水平滚动时看到它。但我希望它始终可见。

【问题讨论】:

  • 你想要滚动条在scrollview还是horizo​​ntalscrollview?

标签: android scroll scrollbar


【解决方案1】:

删除

android:fadeScrollbars="false"

line 或设为true。阅读here。

android:fadeScrollbars => 定义不使用时是否淡出滚动条。

编辑

尝试在您的视图中遵循两行。我删除行 android:fadeScrollbars="false" 并添加以下 2 行。

android:scrollbarFadeDuration="0"
android:scrollbarDefaultDelayBeforeFade="0"

【讨论】:

  • @Tünde,我编辑我的答案。请检查一下。我在我的 GridView 中尝试过。它对我来说很好。
  • 而且你还可以在表格视图中水平滚动?
  • 我的滚动条的淡入淡出属性没有问题。我的问题是它在屏幕之外(如果我有很多表格列),所以我只能在水平滚动时看到它。 (对不起,如果我没有正确解释我的自我......)
  • 我没有在你的布局上实现。我根据“始终可见滚动条”给出了答案。官方 android 网站不建议在另一个 Scrollable View 中使用任何 Scrollable View。
  • 好的,您知道我应该如何以其他方式实现此功能吗?我真的需要我的表格也可以水平和垂直滚动,这就是我找到的方法。
【解决方案2】:

使用 ScrollView.setScrollbarFadingEnabled(false);

【讨论】:

    猜你喜欢
    • 2023-03-17
    • 2011-11-30
    • 2022-06-21
    • 2014-09-21
    • 2012-11-14
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多