【问题标题】:Scrollable progress bar可滚动的进度条
【发布时间】:2017-01-07 19:16:30
【问题描述】:

我正在尝试制作一个可滚动的水平进度条。

因此我将进度条放在水平滚动视图中并将进度条最小宽度设置为 1000(它是我的屏幕宽度的两倍)。

但我还是无法滚动滚动条...

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.pkg.pkg2.scrollableprogressbar.MainActivity">

    <HorizontalScrollView
        android:layout_width="1000dp"
        android:layout_height="wrap_content"
        android:measureAllChildren="true"
        android:background="#e3ece5">

        <ProgressBar
            style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="visible"
            android:id="@+id/progressBar"
            android:progress="50"
            android:minWidth="1000dp"/>
    </HorizontalScrollView>
</LinearLayout>

有什么想法吗? 谢谢!

【问题讨论】:

  • 创建“可滚动”进度条没什么意义。你需要它做什么?
  • @pskink 我有扩展进度条的自定义进度条,我的滚动条上有标记..你知道如何让它可滚动吗?

标签: android android-progressbar android-scrollbar


【解决方案1】:

我通过一项更改尝试了您的解决方案,将水平滚动视图的宽度分配给 wrap_content。
这是我的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:scrollbars="horizontal"
        android:layout_height="wrap_content">

        <ProgressBar
            style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="visible"
            android:id="@+id/progressBar"
            android:progress="50"
            android:secondaryProgress="100"
            android:minWidth="1000dp"
            android:focusable="false"
            android:nestedScrollingEnabled="false" />
    </HorizontalScrollView>

</LinearLayout>

【讨论】:

  • 非常感谢!我在滚动条标签上花了很多时间
【解决方案2】:

将Horizo​​ntalScrollView的layout_width设置为wrap_content

...
<HorizontalScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多