2013-03-06 13 views
19

Làm cách nào để áp dụng hiệu ứng ánh sáng?Cách triển khai loại Progressbar này trong android bằng cách sử dụng tệp xml

Tôi đang cố tạo loại ngang này ProgressBar nhưng không có ý tưởng về hiệu ứng phát sáng làm điểm bắt đầu của tiến trình.

enter image description here

Đây là mã của tôi cho màu gradient

<?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="0dip" /> 

     <solid android:color="#ff9d9e9d"/> 
     </shape> 
    </item> 
    <item android:id="@android:id/secondaryProgress"> 
     <clip> 
      <shape> 
       <corners android:radius="5dip" /> 

      <gradient 
        android:angle="180" 
        android:startColor="#8872f8fc" 
        android:endColor="#886dc0e3" /> 
      </shape> 
     </clip> 
    </item> 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape> 
       <corners android:radius="5dip" /> 

       <gradient 
        android:angle="180" 
        android:startColor="#31c6f7" 
        android:centerColor="#2ea6d1" 
        android:endColor="#2884a6" /> 
      </shape> 
     </clip> 
    </item> 

</layer-list> 
+1

có lẽ đây sẽ giúp http://stackoverflow.com/questions/15898185/holo-progressbar-glow-effect – Elior

+0

U nên kiểm tra này ra http://stackoverflow.com/questions/2819778/custom-drawable-for-progressbar-progressdialog – Niko

+1

Bạn đã đạt được như thế nào để thêm tỷ lệ phần trăm dưới đây để căn chỉnh chính xác với thanh tiến trình? – Abbadon

Trả lời

0

Các hiệu ứng ánh sáng rực rỡ là drawables png với tính minh bạch. Được đặt ở trên cùng bên phải của quy trình hiện tại.

Tạo thanh tiến trình xem tùy chỉnh.

0

Hoặc bạn có thể thêm ImageView vào bố cục của mình. Tạo các drawables cho thanh tiến trình. Sau đó vẽ bên trong ImageView với 2 lớp theo mã. Lớp đầu tiên sẽ là nền và lớp thứ hai sẽ là núm. Viết mã vẽ lại lên Trình nghe onTouch của số lần xem hình ảnh để cập nhật chế độ xem như đã chạm.

2

Bạn có thể sử dụng hình ảnh png cho đầu phát sáng. Sử dụng thẻ < bitmap> bên trong danh sách lớp và căn chỉnh nó sang phải. Tôi đã làm một điều tương tự cho một ứng dụng hoàn toàn khác nhau

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

<item> 
    <shape> 
     <gradient 
      android:angle="270" 
      android:endColor="#4C4C4C" 
      android:startColor="#303030" /> 

     <stroke 
      android:width="0dp" 
      android:color="#000000" /> 

     <corners android:radius="0dp" /> 

     <padding 
      android:bottom="0dp" 
      android:left="5dp" 
      android:right="0dp" 
      android:top="0dp" /> 
    </shape> 
</item> 
<item> 
    <bitmap 
     android:antialias="true" 
     android:gravity="right|bottom|fill_vertical" 
     android:src="@drawable/spinner_down_arrow" /> 
</item> 

</layer-list> 
Các vấn đề liên quan