1. layout/main.xml의 progress bar의 android:progressDrawable 속성을 설정한다.
<ProgressBar
android:progressDrawable="@drawable/new_drawable"
...
</ProgressBar>
2. res/drawable/new_drawable.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" android:drawable="@drawable/backgroundProgress" />
<item android:id="@+android:id/secondaryProgress" android:drawable="@drawable/secondaryProgress" />
<item android:id="@+android:id/progress" android:drawable="@drawable/progress" />
</layer-list>
3. res/drawable 디렉토리 밑에 다음의 파일을 생성한다.
backgroundProgress.png
secondaryProgress.png
progress.png
png파일을 생성하지 않고 drawable로 작성하려면
2b. res/drawable/new_drawable.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>
<corners android:radius="0dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="0dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="0dip" />
<gradient
android:startColor="#ff0000"
android:centerColor="#00ff00"
android:centerY="0.75"
android:endColor="#0000ff"
android:angle="0"
/>
<stroke android:width="3dp" color="#000000"/>
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</clip>
</item>
</layer-list>
[출처] progress bar 모양 바꾸기|작성자 treebystream
'Android > Tip&Tech' 카테고리의 다른 글
[펌]svn 구축 (0) | 2012.02.23 |
---|---|
[펌]ViewPager 에 관한 설명 (0) | 2012.02.17 |
액티비티와 태스크 (0) | 2012.02.01 |
안드로이드 최신버전 확인하기 (0) | 2012.01.30 |
마켓 링크 확인하기 (1) | 2012.01.30 |