Skip to content

Instantly share code, notes, and snippets.

@pennya
Last active March 24, 2019 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pennya/5fd019406287a575b9d6bbc4a7d41b1c to your computer and use it in GitHub Desktop.
Save pennya/5fd019406287a575b9d6bbc4a7d41b1c to your computer and use it in GitHub Desktop.
ProgressBar Style 쉽게 변경하는 방법
style.xml 파일에서
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="progressBarStyle" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:indeterminateDrawable">@drawable/progress_bar_drawable</item>
</style>
</resources>
/res/drawable/progress_bar_drawable.xml 하나만들고
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/colorPrimaryDark"/>
</shape>
</clip>
</item>
</layer-list>
progressbar 구현하는 곳에서
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBarWaitingObjects"
style="@style/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:indeterminate="true" />
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment