2012-06-06 39 views
7

i có mãdi chuyển progressbar của tôi với một hình ảnh android

đây là một thanh tiến trình đó điền với một màu đỏ

<?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> 

và trông như thế này

enter image description here

bây giờ tôi muốn thêm hình ảnh để di chuyển cùng lúc thanh tiến trình đầy lên như hình bên dưới

enter image description here

hãy giúp tôi

cảm ơn trước

Trả lời

8

Có lẽ bạn có thể phong cách một seekbar (thay vì một progressbar) sử dụng layerlist của bạn và thêm hình ảnh của bạn như núm trình kiểm soát?

<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

cảm ơn Damian cho câu trả lời. Bạn có một ví dụ làm thế nào để làm điều đó xin vui lòng – japuentem

+0

Có, chỉ cần cập nhật câu trả lời của tôi ở trên với mã số – Damian

+0

Cảm ơn một lần nữa, hãy để tôi thử mã và gửi bất kỳ bình luận – japuentem

6

Tôi nghĩ hình ảnh chuyển động này có thể được thực hiện bằng seekbar, hình ảnh này được gọi là Thum drawable

enter image description here

Bạn có thể thử tutorial này nó sẽ giúp bạn rất nhiều !!

đặt thuộc tính thanh tìm kiếm android:thumb="@drawable/seek_thumb" để trỏ đến hình vẽ mà bạn muốn

+0

Ví dụ rất tốt K_Anas, bây giờ tôi có một cái nhìn tốt hơn về seekbar – japuentem

+0

Bạn được chào đón !! –

Các vấn đề liên quan