android int color = contextCompat.getColor (getContext (), mcolorresourceId);

LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear);
int color = ContextCompat.getColor(getContext(), mColorResourceId);
linearLayout.setBackgroundColor(color);
Ismail Hossain