[英]custom progress drawable not showing sometimes
我有一個非常奇怪的問題 - 我為進度條定義了一個自定義進度drawable
有時它顯示,有時它不顯示。
我嘗試清理我的項目,重新啟動eclipse甚至重新啟動計算機。
它仍然發生。
這是進度可繪制的xml:
<?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
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp" />
<gradient
android:startColor="#6f7754"
android:endColor="#858762"
android:angle="90"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp" />
<gradient
android:startColor="#ffba00"
android:endColor="#af6c03"
android:angle="90"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="5dp" />
<gradient
android:startColor="#ffba00"
android:endColor="#af6c03"
android:angle="90" />
</shape>
</clip>
這是我使用它的xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="2dp"
android:background="@drawable/quick_action_item_btn">
<ImageView
android:id="@+id/icon"
android:layout_width="21dp"
android:layout_height="21dp"
android:scaleType="centerInside"/>
<ProgressBar
android:id="@+id/progress"
android:layout_width="20dp"
android:layout_height="4dp"
android:layout_marginTop="2dp"
style="@android:style/Widget.ProgressBar.Horizontal"
android:progressDrawable="@drawable/achievement_progress_bar"/>
</LinearLayout>
嘗試這個
android:indeterminateDrawable="@drawable/yourXML"
它對我有用..
也許這與此問題類似... SharedPreferences.onSharedPreferenceChangeListener未被一致地調用
自定義xml是否定義為活動的變量? 如果沒有,也許垃圾收集器正在收集它。 我的建議是使它成為類的一個字段變量(活動類)。
它對我來說很好。 只需將你的indeterminateDrawable設置為你的custum xml文件。它應該沒問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.