Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't use setStrokeColor method for material button Android

I’m using Material outlined button in Android Studio (material version is 1.4.0).
I wanted to change outline color when button is pressed. so,

binding.activeButton.setOnClickListener{

  binding.activeButton.setStrokeColor(Color.parseColor("#FFFFFF"))
}

However, I can’t use setStrokeColor method.
It says "Unresolved reference: setStrokeColor"

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I still can use app:strokeColor="@color/white" in the XML file, but I can’t use setStrokeColor method in an activity file.
What would be the reason ? Is it because of material design version?

>Solution :

Try it:

       binding.activeButton.setStrokeColorResource(R.color.back_color_green_btn)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading