2012-06-06 17 views
7

我有這樣的代碼動我的進度與Android的圖像

是一個進度條,與紅色

<?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> 
      <gradient 
      android:startColor="#c3c3c3" 
       android:centerColor="#c3c3c3" 
       android:centerY="0.75" 
       android:endColor="#7f7f7f" 
       android:angle="270"/> 
      <padding android:left="1dp" 
      android:top="1dp" 
      android:right="1dp" 
      android:bottom="1dp"/> 
     <corners android:radius="10dp"/> 
    </shape> 
</item> 

<item android:id="@android:id/secondaryProgress"> 
    <clip> 
     <shape> 
      <gradient 
       android:startColor="#234" 
       android:centerColor="#234" 
       android:centerY="0.75" 
       android:endColor="#a24" 
       android:angle="270"/> 
      <padding android:left="1dp" 
       android:top="1dp" 
       android:right="1dp" 
       android:bottom="1dp"/> 
      <corners android:radius="10dp"/> 
      </shape> 
    </clip> 
</item> 

<item android:id="@android:id/progress"> 
    <clip> 
     <shape> 
      <gradient 
       android:startColor="#a42c48" 
       android:centerColor="#a42c48" 
       android:centerY="0.75" 
       android:endColor="#eb3e67" 
       android:angle="270"/> 
      <padding android:left="1dp" 
       android:top="1dp" 
       android:right="1dp" 
       android:bottom="1dp"/> 
      <corners android:radius="10dp"/> 
     </shape> 
    </clip> 
    </item> 
</layer-list> 

填寫這個樣子

enter image description here

現在我想要添加圖像同時移動進度條像下面的圖像填充

enter image description here

請使用您的layerlist幫我提前

回答

8

也許你可以樣式搜索條(而不是進度)

感謝,並添加您的圖像作爲拇指洗滌?

<SeekBar 
    android:id="@+id/seekBar1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:thumb="@drawable/your_android_image" 
    android:progressDrawable="@drawable/your_layerlist_drawable"/> 
+0

感謝達米安的答案被拉伸。你有一個例子如何做到這一點請 – japuentem

+0

是的,只是更新我的回答上面的代碼 – Damian

+0

再次感謝,讓我試試代碼並發表任何評論 – japuentem

6

我覺得這個活動圖像可以使用搜索條來完成,這種圖像被稱爲吞繪製

enter image description here

你可以試試這個tutorial它會幫助你很多!

設置搜索條屬性android:thumb="@drawable/seek_thumb"指向,你的願望

+0

非常好的示例K_Anas,現在我對seekbar有更好的瞭解 – japuentem

+0

不客氣! –