自定义android中的垂直进度条

时间:2014-08-09 14:59:03

标签: android progress-bar

如何将针宽(进度剪辑)设置为比垂直进度条的背景形状更窄? 我已添加,但剪辑填满了整个视图。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:id="@android:id/background">
     <shape>
         <corners android:radius="5dip" />
          <gradient
            android:startColor="#ff9d9e9d"
            android:centerColor="#ff5a5d5a"
            android:centerY="0.75"
            android:endColor="#ff747674"
            android:angle="180"
  />
     </shape>
 </item>
 <item android:id="@android:id/progress">
     <clip
         android:clipOrientation="vertical"
         android:gravity="bottom">
         <shape>
             <corners android:radius="50dip"/>
             <solid android:color="#FF0000"/>
             <size android:width="2dp"/>
             <stroke
                 android:width="1dp"
                 android:color="#000000" />
         </shape>
     </clip>
 </item>
</layer-list>

1 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dip" />
            <gradient
                android:startColor="#ff9d9e9d"
                android:centerColor="#ff5a5d5a"
                android:centerY="0.75"
                android:endColor="#ff747674"
                android:angle="180" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <clip
            android:clipOrientation="vertical"
            android:gravity="bottom">
            <layer-list>
                <item
                    android:left="5dp"
                    android:top="5dp"
                    android:right="5dp"
                    android:bottom="5dp">
                    <shape>
                        <corners android:radius="50dip" />
                        <solid android:color="#FF0000" />
                        <size android:width="2dp" />
                        <stroke
                            android:width="1dp"
                            android:color="#000000" />
                    </shape>
                </item>
            </layer-list>
        </clip>
    </item>
</layer-list>

see my blog