neild001 / SeekArc

Circular SeekBar view for Android
MIT License
892 stars 296 forks source link

updating progress and arc colors programmatically #78

Open danwguy opened 4 years ago

danwguy commented 4 years ago

I am not sure if this is possible, but I am in a scenario where we want to be able to change the arc color and background color based on certain actions. What I have noticed so far is when calling progress.setProgressColor(int) or progress.setArcColor(int) it uses tinting to change the color. I have it setup in my xml with a progress color of orange and leaving the arc color as default...

<com.triggertrap.seekarc.SeekArc
        android:id="@+id/seek"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:layout_marginStart="32dp"
        android:layout_marginEnd="32dp"
        android:layout_marginTop="8dp"
        android:paddingStart="30dp"
        android:paddingEnd="30dp"
        app:arcWidth="30dp"
        app:layout_constraintBottom_toTopOf="@id/bottomguideline"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/topguideline"
        app:layout_constraintVertical_bias="0.5"
        app:progress="30"
        seekarc:progressColor="@color/stepup_orange"
        seekarc:arcColor="@android:color/darker_gray"
        app:progressWidth="30dp"
        app:roundEdges="true"
        app:sweepAngle="360"
        seekarc:enabled="false"
        seekarc:max="100"
        seekarc:rotation="0"
        seekarc:startAngle="0"
        seekarc:touchInside="false"/>

Now when I call progress.setProgressColor(int) I am using a red color #D81B60 however the progress color is coming out purple/gray/blue-ish. It isn't actually coming out that red color. I'm not sure if it's possible since I think the only way to update color dynamically on rendered graphics is using tinting, but I was hoping there was a way, or someone knows how to do this, or maybe you can build it in. Please let me know, this is actually a very important part of this project. Thank you

BhargavBhanshali commented 3 years ago

use progress.setProgressColor (ContextCompat.getColor (context,R.color.YOUR COLOR));