Home > Software design >  Can't use setStrokeColor method for material button Android
Can't use setStrokeColor method for material button Android

Time:12-05

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

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?

CodePudding user response:

Try it:

       binding.activeButton.setStrokeColorResource(R.color.back_color_green_btn)
  • Related