Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Holo Style Horizontal ProgressBar when minSdkVersion Less than 11?

I build an android project with targetSdkVersion="15" & minSdkVersion="8", then add a horizontal progressbar in activity, but it not holo style when I run this project with android jelly bean.

What can I do? to edit values-v14 style.xml?

layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ProgressBar
    android:id="@+id/countdown_progressbar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    style="@android:style/Widget.ProgressBar.Horizontal"
    android:max="30" />

values & values-v14 style.xml

<style name="AppTheme" parent="Theme.Sherlock.Light" />

Thanks a lot.

like image 773
Shawn Avatar asked Oct 04 '22 22:10

Shawn


2 Answers

You will need to get the resources for the progessbar. You can get them from http://android-holo-colors.com/ with the styles.xml file or use the HoloEverywhere library: https://github.com/Prototik/HoloEverywhere

like image 152
Davidz17 Avatar answered Oct 10 '22 04:10

Davidz17


Use ?android:attr/progressBarStyleHorizontal instead of @android:style/Widget.ProgressBar.Horizontal.

As I understand this, ?android:attr/progressBarStyleHorizontal is current theme styled progress bar style whereas @android:style/Widget.ProgressBar.Horizontal is just plain android progress bar style.

The code should look like:

<ProgressBar
    android:id="@+id/countdown_progressbar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    style="?android:attr/progressBarStyleHorizontal"
    android:max="30" />
like image 39
sidon Avatar answered Oct 10 '22 04:10

sidon