【问题标题】:Creating secondary progress bar using multiple clips drawable使用可绘制的多个剪辑创建辅助进度条
【发布时间】:2015-09-22 05:25:25
【问题描述】:

我正在使用带有可绘制剪辑图层列表的 imageview 创建进度条,它的工作原理就像一个魅力。代码如下:

背景drawable的xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:id="@android:id/background">
        <bitmap android:src="@drawable/energy_backing" >
        </bitmap>
    </item>
    <item android:id="@android:id/progress">
        <clip
            android:clipOrientation="horizontal"
            android:drawable="@drawable/energy_full"
            android:gravity="left" />
    </item>

</layer-list>

进度条的xml:

   <ImageView
                android:id="@+id/pbEnergyBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_marginBottom="20dp"
                android:layout_centerHorizontal="true"
                android:src="@drawable/progress_bar_energy2" />

当然我可以通过调用 imageview.setImageLevel(progress) 来设置进度。

我的问题是,我怎样才能添加一个像默认 ProgressBar 中的辅助进度条?

我想添加另一个可绘制的剪辑,但是如何在两个不同的剪辑上调用 setLevel 两次?任何指导!

谢谢

【问题讨论】:

    标签: android android-drawable


    【解决方案1】:

    您可以添加另一个带有第二层列表的 ImageView 并将其完全放在第一个 ImageView 的顶部...


    编辑:实际上,您可以将ProgressBar 与您的drawable 一起使用。

    • 使用&lt;item android:id="@android:id/secondaryProgress"&gt;向您的列表中添加另一层

    • ProgressBar 中设置android:progressDrawable="@drawable/progress_bar_energy2"

    看看这是否有效。

    【讨论】:

    • 其实这是个好主意。我宁愿诚实地处理一种观点,但如果我没有得到另一个答案,那么我会接受你的。谢谢
    • 添加了另一个想法来回答。
    • 对图像使用进度条不能正常工作。这就是我使用图像视图的原因。如果我使用带有图像的进度条,则图像被截断并且尺寸不正确
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    相关资源
    最近更新 更多