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