0

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

因此,我将进度条放在水平滚动视图中并将进度条最小宽度设置为 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>

任何的想法?谢谢!

4

2 回答 2

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>
于 2016-08-31T09:26:03.637 回答
0

Horizo​​ntalScrollView的 layout_width 设置为wrap_content

...
<HorizontalScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
...
于 2016-08-31T09:35:18.973 回答