Former President Barack Obama took a shot Wednesday at some Hispanics who voted for President Donald Trump, saying they did not care about his "racist" remarks because of their alignment on social views.

"People were surprised about a lot of Hispanic folks who voted for Trump, but there’s a lot of evangelical Hispanics who, the fact that Trump says racist things about Mexicans, or puts undocumented workers in cages, they think that’s less important than the fact that he supports their views on gay marriage or abortion," he said on "The Breakfast Club" radio show.

Trump surprised political onlookers with his improved showing with Hispanic voters in 2020 from 2016, helping him to comfortable victories in states with significant Hispanic populations like Texas and Florida. His focus on working-class issues and stance against socialism was appealing to some Latinos, although a majority still voted for President-elect Joe Biden.

Nevertheless, the trend worried Democrats who assumed Trump's strict immigration policies would alienate the demographic.

OBAMA ADMITS READING MARX 'AS A STRATEGY FOR PICKING UP GIRLS'

Some critics attacked Obama for what they viewed as divisive comments, reminiscent of his 2008 reference to "bitter" working-class voters who "cling" to guns and religion. Others noted the "cages" he referred to from the Trump administration's family separation policy were built during his presidency.

Obama, who is promoting his latest memoir, "A Promised Land," said people who live in liberal cities like New York, Los Angeles, and Washington, D.C., often forget the country's enormous size and range of viewpoints.

CLICK HERE TO GET THE FOX NEWS APP

"It's hard winning in Georgia, just like it's hard winning in Iowa, just like it's hard winning in a lot of the country," he said.