Tuesday, 24 August 2021

How to setColorFilter to a png image

I am already using setColorFilter() to add color to these lines. The original color for this line is yellow. I use red or green depend on some statement.

This is what I have so far: Someone helped me to do this: How to set filter property in ImageView Android studio

enter image description here

But now I need to add color under the line...like this:

enter image description here

sparkline.setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);
sparkline.setImageResource(R.drawable.btc_spike);

<androidx.constraintlayout.utils.widget.ImageFilterView
                android:layout_width="80dp"
                android:layout_height="50dp"
                android:id="@+id/sparkline"
                android:layout_marginRight="2dp"
                app:saturation="80"
                app:brightness="0.85"
                app:crossfade="0.0"
                app:warmth="10"
                android:src="@drawable/btc_spike" />

I also found this page but not sure if it wants me to add another image on top of this or something else...

https://developer.android.com/reference/android/graphics/PorterDuff.Mode#MULTIPLY



from How to setColorFilter to a png image

No comments:

Post a Comment