【问题标题】:Rounded progress bar in Progressbar - AndroidProgressbar 中的圆形进度条 - Android
【发布时间】:2014-04-18 08:38:28
【问题描述】:

我正在尝试使进度条变圆,背景工作正常,但进度条(橙色)没有变圆,有什么解决方案吗?

这是我的应用程序的图像:

这就是我想要的:

这是我的进度条的代码:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
    <shape>
        <corners android:radius="13dip" />
        <gradient
            android:angle="270"
            android:centerColor="#ff747674"
            android:centerY="0.5"
            android:endColor="#ff9d9e9d"
            android:startColor="#ff9d9e9d" />
    </shape>
</item>

<item android:id="@android:id/progress">
    <clip>
        <shape>
            <corners
                android:radius="13dip" />
            <gradient
                android:startColor="#f3c30b"
                android:centerColor="#efa200"
                android:centerY="0.5"
                android:endColor="#ce7428"
                android:angle="270"
                />
        </shape>
    </clip>
</item>

【问题讨论】:

  • 使用 ClipDrawable 会切割你的圆形 Drawable,这就是为什么你看不到圆形右侧,使用自定义 Drawable reacring 来改变关卡
  • 你能给我举个例子吗?
  • class D extends Drawable { ... 并在内部覆盖 onLevelChange 调用 invalidateSelf,因此任何对 setLevel 的调用都会使 Drawable 无效

标签: android progress-bar progress rounded-corners


【解决方案1】:

将&lt;clip&gt;..&lt;/clip&gt; 替换为&lt;scale android:scaleWidth="100%"&gt;..&lt;/scale&gt;。

【讨论】:

    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-05
    • 1970-01-01
    相关资源
    最近更新 更多