Mac Davis, a singer-songwriter who parlayed a string of hits for Elvis Presley into a varied career as an actor and recording artist, blending country and pop in chart-topping songs such as “Baby Don’t Get Hooked on Me” and playing a quarterback in the football movie “North Dallas Forty,” died Sept. 29 in Nashville. He was 78.

His manager, Jim Morey, announced the death in a statement, after a tweet in which Mr. Davis’s family revealed that he was “critically ill following heart surgery.”

With a Texas drawl and country charm, Mr. Davis became a crossover country-pop success in the early 1970s, performing at cow palaces and casinos, writing a No. 1 song that started out as a joke with his producer, and hosting his own musical variety show for three years on NBC. His songwriting process was simple, he said: “I try to tell the truth and hope it rhymes.”

Mr. Davis initially worked as a record-label promoter and songwriter for other artists, collaborating with Glen Campbell and Bobby Goldsboro as well as Kenny Rogers and the First Edition. He broadened his range even further in recent years, working with the Swedish DJ Avicii, Weezer frontman Rivers Cuomo and singer-songwriter Bruno Mars.

As a composer, Mr. Davis was perhaps best known for his work for Presley, at a time when the King of Rock and Roll was beginning to pivot from movies back to live performances. Mr. Davis was writing a song intended for Aretha Franklin, “A Little Less Conversation,” when it was picked up for Presley’s 1968 movie musical “Live a Little, Love a Little.”

Co-written by Billy Strange, a guitarist and arranger, “A Little Less Conversation” acquired a second life after it was featured in the 2001 heist film “Ocean’s Eleven” and remixed by Dutch musician Junkie XL, in a version that went to No. 1 in more than two dozen countries.

It was followed by hits including “Memories,” for Presley’s 1968 comeback special on NBC; “Don’t Cry Daddy,” written amid the breakup of Mr. Davis’s first marriage; and “In the Ghetto,” about “a poor little baby child” who grows up hungry, steals a car and is shot dead in Chicago. The song reached No. 3 on the charts and was featured on “From Elvis in Memphis” (1969), one of Presley’s most celebrated albums.

Mr. Davis, who was White, said “In the Ghetto” was inspired by memories of a childhood friend, the son of one of his father’s construction employees, who lived in a Black section of Lubbock, Tex.

“They had dirt streets and broken glass everywhere,” he told American Songwriter magazine. “I couldn’t understand how these kids could run around barefoot on all that broken glass; I was wondering why they had to live that way and I lived another way.”

While writing for Presley, Mr. Davis began performing his own music on TV variety shows. His song “I Believe in Music” climbed the pop charts after it was covered by the band Gallery, and in 1972 Mr. Davis broke through with “Baby Don’t Get Hooked on Me.”

As Mr. Davis told the story, he wrote the song after his producer, Rick Hall, asked him to craft “a ‘hook’ song, one with a repeat phrase which is singles oriented.” As a joke, he took the prompt literally, suggesting the line, “Don’t get hooked on me.” Hall urged him to go into the recording studio immediately. It went to No. 1 for three weeks.

Mr. Davis had a wry sense of humor that helped him jump from music to film and television. He lent his voice to characters in the animated TV series “King of the Hill,” played country singer Rodney Carrington’s father-in-law on the ABC sitcom “Rodney” and appeared in movies such as “North Dallas Forty” (1979), based on a best-selling novel by former Dallas Cowboys wide receiver Peter Gent.

Examining the decadent, drug-fueled exploits of a pro football team, “North Dallas Forty” starred Nick Nolte as a receiver modeled on Gent, with Mr. Davis as a quarterback who mirrored Cowboys star Don Meredith.

But his Hollywood career cratered after “The Sting II” (1983), a disastrous follow-up to the Paul Newman and Robert Redford caper film, and Mr. Davis went into early retirement a few years later. He battled alcoholism before making his way to Broadway in 1992, taking over the title role in the musical “Will Rogers Follies.”

“When I look back, my life has been a succession of struggle, struggle, struggle, then go right to the top,” he told the New York Daily News. Mr. Davis, who joined the cast as a replacement for Keith Carradine, called his star turn “the biggest turnaround in my life,” following three years in which he improved his golf game, fell deeper into whiskey and finally checked himself into the Betty Ford Center.

“I let the blues get to me,” he said. But in playing Rogers, the self-deprecating cowboy, actor and vaudeville star, he said he was learning to be humble — a process of self-improvement he had humorously chronicled more than a decade earlier, in the tongue-in-cheek country hit “It’s Hard to Be Humble.”

“To know me is to love me, I must be a hell of a man,” he sang. “Oh Lord, it’s hard to be humble; but I’m doin’ the best that I can!”

By most accounts, he was born Morris Mac Davis in Lubbock on Jan. 21, 1942, although some reports say his middle name was MacClellan.

His parents divorced when he was 9, and Mr. Davis turned from religious music in his Presbyterian church choir to the rebellious new rock and roll of artists like Presley and Buddy Holly, a fellow Lubbock native who performed at the local roller rink.

“Back then, we didn’t think anyone from Lubbock could be famous,” Mr. Davis told the Lubbock Avalanche-Journal in 2008. “Buddy was on the radio, but we thought they just played him on the Lubbock stations. Then I saw him drive down College Avenue in a new, black and pink Pontiac Catalina convertible. New glasses. New teeth. And girls in the car. And I said if Buddy can do it, so can I.”

After graduating from high school, Mr. Davis joined his mother and stepfather in Atlanta, where he worked with the city probation department while singing in a rock band. He later became a promoter for Vee-Jay and Liberty Records and, after moving to Los Angeles in 1966, launched his songwriting career.

Mr. Davis turned toward a more overt country sound in the 1980s and partnered with Dolly Parton, co-writing her song “White Limozeen” and singing with her on “Wait ’Til I Get You Home.”

His marriages to Fran Cook and Sarah Barg, who later married his friend and golf partner Glen Campbell, ended in divorce. In the early 1980s he married Lise Gerard, a nurse. He had a son, Scott, from his first marriage, and two children, Noah and Cody Davis, from his third. They survive him, as does his mother; a sister; and a granddaughter.

While Mr. Davis’s music was far from universally acclaimed — the “New Rolling Stone Record Guide” once called it “sententious Muzak” — he was inducted into the Songwriters Hall of Fame in 2006. He largely stopped recording his own music after 1994, when he released the mischievously titled album “Will Write Songs for Food.”