2012-01-31 40 views
13

Có thể thay đổi hộp thoại tiến trình của ProgressBar không. Nếu có, thì làm thế nào tôi có thể làm điều đó?Thay đổi kiểu của ProgressDialog

+0

loại kiểu nào bạn muốn .... ??? –

+0

Khá dễ dàng để làm điều này và mã có thể được tìm thấy tại akkilis

+0

Cảm ơn bạn đã trả lời nhanh chóng, tôi chỉ muốn thay đổi ProgressBar mặc định hoạt hình với hoạt ảnh tùy chỉnh của tôi. – Aram

Trả lời

5

Bạn có thể tạo kiểu tiến bộ của bạn hộp thoại theo cách này: tạo một file drawable với hình dạng chiếc nhẫn của bạn (circular_progress_dialog.xml)

<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
android:fromDegrees="270" 
android:toDegrees="270"> 
<shape 
    android:innerRadiusRatio="2.5" 
    android:shape="ring" 
    android:thickness="2dp" 
    android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 --> 

    <gradient 
     android:angle="0" 
     android:endColor="@color/main_background" 
     android:startColor="@color/main_orange" 
     android:type="sweep" 
     android:useLevel="false" /> 
</shape> 
</rotate> 

một phong cách thanh tiến trình của bạn

<style name="ProgressBar" parent="@android:style/Widget.ProgressBar"> 
    <item name="android:layout_centerHorizontal">true</item> 
    <item name="android:layout_centerVertical">true</item> 
    <item name="android:visibility">gone</item> 
    <item name="android:background">@color/transparency_pleca</item> 
    <item name="android:indeterminateDrawable">@drawable/circular_progress_dialog</item> 
</style> 

Thông báo của bạn " android: indeterminateDrawable "property

Yout có thể tạo một phiên bản ProgressDialog và thêm phong cách của bạn với

// create progressDialog 
final ProgressDialog myProgressDialog = new ProgressDialog(MyActivity.this); 
myProgressDialog.setProgressStyle(R.style.ProgressBar) 
myProgressDialog.show(); 
Các vấn đề liên quan