Reputation: 5353
i am using progressbar in toolbar ,by default its loading Accent color,i want to customize the color of progressbar .i am using support library 22.0.0
?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_aweseome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="?attr/colorPrimary">
<ProgressBar
android:id="@+id/progress_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:indeterminate="true"
/>
so i tried to change progressbar color using setColor filter
progressBar = (ProgressBar) findViewById(R.id.progress_spinner);
progressBar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#FF104D"),//Pink color
android.graphics.PorterDuff.Mode.MULTIPLY);
progressBar.setVisibility(View.VISIBLE);
but i tried to set as pink ,but out put is some other different color.
progressBar.getIndeterminateDrawable().setColorFilter(Color.WHITE,android.graphics.PorterDuff.Mode.MULTIPLY)),
when i set as white color,its not even showing up..
Upvotes: 1
Views: 831
Reputation: 802
Try with PorterDuff.Mode.SRC_IN
. It works for me, at least with SeekBar
.
Upvotes: 0
Reputation: 3688
try this ,
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="20"
android:useLevel="false" >
<size
android:height="48dp"
android:width="48dp" />
<gradient
android:centerColor="@color/tranparent"
android:centerY="0.50"
android:endColor="@color/red"
android:startColor="@color/tranparent"
android:type="sweep"
android:useLevel="false" />
</shape>
Upvotes: 1
Reputation: 5258
Use :
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/progress"
/>
use create progress.xml in your drawable folder :
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="720" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<size
android:height="86dip"
android:width="86dip" />
<gradient
android:angle="0"
android:endColor="@color/blue"
android:startColor="@android:color/transparent"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
Upvotes: 4