Just add the "freelancer" line to your resume and voila, you've no longer been unemployed for a few years. This also assumes that you've been doing something that could qualify as freelancing like working on some phone apps or a website or something.
If you've been sitting on your ass for 2 years, yeah it's going to look pretty bad to employers.
This works outside the computer related industry as well. I was made redundant from a managerial job in teaching. I did some authoring of e-learning materials, did some sessional work (fee paid teaching) for a couple of local institutions, then found a salaried job within six months. At no time was I officially unemployed. My CV is seamless.
If they've been sitting on their ass. But when the economy tanked, a lot of people took the money they saved during the boom years and traveled the world. Or learned a new programming language. Or built something useful. So 2 year gaps in work history shouldn't be a deal killer. If they are, the system is truly, tragically broken.
If you've been sitting on your ass for 2 years, yeah it's going to look pretty bad to employers.