How to set layout background tint from string programmatically?

I figured I can't use getColorStateList() so I searched for another way to do it. At the end I was able to set color tint using the following code:

LinearLayout someLayout=(LinearLayout)view.findViewById(R.id.someLayout);
        someLayout.getBackground().setColorFilter(Color.parseColor("#ff8800"), PorterDuff.Mode.SRC_ATOP);

This worked as if I changed the backgroundTint property in the xml file, so it's perfect for my problem.


I was able to manage using the following line. change it to your circumstances.

myView.getBackground().setTint(currentView.getResources().getColor(R.color.colorAccent));