A fire at a two-story apartment building in Campbell left four homes uninhabitable Tuesday evening, the Santa Clara County Fire Department said.