Consider:
styles.xml
<style name="BlueTheme" parent="@android:style/Theme.Black.NoTitleBar"> <item name="theme_color">@color/theme_color_blue</item> </style>
attrs.xml
<attr name="theme_color" format="reference" />
color.xml
<color name="theme_color_blue">#ff0071d3</color>
and finally drawable progress_bar.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> <stroke android:width="2px" android:color="#ff515151" /> <solid android:color="@color/transparent" /> </shape> </item> <item android:id="@android:id/progress"> <clip> <shape> <solid android:color="?attr/theme_color" /> </shape> </clip> </item> </layer-list>
when using the progress bar:
<ProgressBar android:id="@+id/progressBarStartup" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:progressDrawable="@drawable/progress_bar" android:visibility="visible" />
I get a runtime error . Android seems to be unable to get a color theme.
06-24 16:35:57.032: E/AndroidRuntime(3493): java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx.xxx.activities.startup.ActivityStartup}: android.view.InflateException: Binary XML file line
android android-resources android-theme
Seraphim's Jun 24 '13 at 14:41 2013-06-24 14:41
source share