Cain (0-2) righted the ship to finish with three scoreless innings, allowing seven runs on seven hits in the six frames altogether. He did not walk a batter and struck out four, but the Giants are now 0-4 in his starts.
"It didn't really matter what it was in those three innings, everything was coming back to the middle," Cain said. "It's just not really repeating the delivery and being consistent in making pitches. I have to find a way to do a better job of that. I've got to kind of keep taking small steps and doing the right things."
Gallardo (1-1), in his first appearance since he was cited for drunken driving early Tuesday morning in Milwaukee, allowed one run on five hits in six innings.
"I don't want to say I approached the game different, but with something like that, you have to go out there and prove that you're capable of getting over it -- go out there and focus," Gallardo said. "From here on out, that's the main thing -- go out there and win ballgames for the team."
The home run was the 11th of his career, most among active pitchers. Cain said he was trying to spot a fastball outside, but it tailed back in.
Prior to Gallardo's blast, Yuniesky Betancourt singled in Carlos Gomez, who reached base when home-plate umpire Jerry Meals ruled Gomez was hit in the hand by a pitch. Giants manager Bruce Bochy argued that the ball, which ricocheted well down the first-base line, struck the bat instead. The umpires got together to talk it out, but the call stood, and Gomez stole second before coming around to score.
"You hate to see that," Bochy said. "Jerry Meals said, 'I couldn't tell what happened.' He thought it hit his elbow pad. We heard wood. There's no way that ball is going to go where it went unless it hit the bat. We got a bad break there, but with that said, we compounded the problem and made a couple mistakes."
Cain crouched momentarily in frustration after hanging a breaking ball to Lucroy in the third, one that gave the Brewers a 7-0 lead.
"In my mind, I'm thinking at worst, I'm going to bounce it and it's just going to be (3-2), and the pitch is just sitting there," Cain said.
There was a bright spot for the Giants: Brandon Crawford extended his career-best hitting streak to 11 games, leading off the second with a single and the fourth with a double. His home run against Alfredo Figaro in the ninth left him a triple shy of the cycle. It was his debut in the fifth spot of the lineup, elevated from eighth thanks to his recent run of success and an off-day for cleanup hitter Buster Posey.
"You have to like what he's doing," Bochy said. "He was, I guess, the silver lining in the last few games where he swung the bat.
"Last year, I thought he made nice adjustment and really made huge strides in his hitting and did this spring. He battles up there well, he shortens up when he has two [strikes]. He's put up some good at-bats."
Crawford has hit .444 (16-for-36) in the run, and he has reached base safely in 14 straight games. He scored both of his team's runs, also trotting across when Brandon Belt provided a sacrifice fly in the fourth to make it 7-1.
It marked the sixth time Cain had allowed three or more homers in a game, one shy of his career mark of four (set twice). He last allowed three home runs in one contest on July 21 of last year, and he's never done it more than once in a season.
"The long ball killed us in games we got beat [on the road trip]," Bochy said. "We had a hard time keeping the ball in the ballpark this series. I will say, [Cain] gave us a nice effort. He regrouped and made a nice adjustment and pitched great the last three innings. When you have three two-run homers, it's hard to overcome."
The Giants were out-homered, 15-3, in the seven-game road trip against the Cubs and Brewers. Throw in the fact that the team was prone to the big inning, allowing a frame of three runs or more in four straight games and five times on the trip.
"Our strength is our starters, and they had a tough time here," Bochy said. "Balls up in the zone, every one of them, which is usually the case on a home run. We didn't get away with them. It seems like every time we made a mistake, they took advantage of it."
It was the Brewers' first sweep of San Francisco since July 18-20 of 2008 and first sweep at Miller Park since April of the same season.
"[Barry] Zito's throwing so well and he had a hiccup here,' Bochy observed. "'[Ryan Vogelsong] threw a pretty good game, that was a tough loss last night. Matty was just off. We know how good these guys are. They'll get back on track. We've faced two good pitchers who did a good job on us."
JR Radcliffe is a contributor to MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.