【问题标题】:What should the images look like for a ProgressDrawable layer-list?ProgressDrawable 图层列表的图像应该是什么样的?
【发布时间】:2010-12-12 15:02:15
【问题描述】:

我正在自定义 Android 中的 HORIZONTAL ProgressBar 的外观,我必须使用三张不同的图片,一张用于背景,一张用于secondaryProgress,一张用于进度。

我的猜测是,背景必须是实际的完整条形图像才能填充进度,类似于与 ProgressBar 视图布局宽度和高度的尺寸相匹配的灰色条形图像?

其他人呢?

【问题讨论】:

    标签: android image progress-bar


    【解决方案1】:

    看看progress_horizo​​​​ntal.xml在Android核心中是如何定义的 - 你可以将它作为参考:

    <?xml version="1.0" encoding="UTF-8"?>
    <layer-list
      xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:id="@id/background">
            <shape>
                <corners android:radius="5.0dip" />
                <gradient android:startColor="#ff9d9e9d" android:endColor="#ff747674" android:angle="270.0" android:centerY="0.75" android:centerColor="#ff5a5d5a" />
            </shape>
        </item>
        <item android:id="@id/secondaryProgress">
            <clip>
                <shape>
                    <corners android:radius="5.0dip" />
                    <gradient android:startColor="#80ffd300" android:endColor="#a0ffcb00" android:angle="270.0" android:centerY="0.75" android:centerColor="#80ffb600" />
                </shape>
            </clip>
        </item>
        <item android:id="@id/progress">
            <clip>
                <shape>
                    <corners android:radius="5.0dip" />
                    <gradient android:startColor="#ffffd300" android:endColor="#ffffcb00" android:angle="270.0" android:centerY="0.75" android:centerColor="#ffffb600" />
                </shape>
            </clip>
        </item>
    </layer-list>
    

    【讨论】:

    • 完美。我以前去过,但忘记了。你能告诉我如何找到安卓源吗?
    • 我想有多种方法,在网上找到它(或从 Android git repo 中查看)。但我所做的只是用 apktool (code.google.com/p/android-apktool) 解压缩 C:\android-sdk-windows-r04\platforms\android-8\android.jar
    猜你喜欢
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 2012-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多