When a script adds a line of dialogue toward the close explaining a film’s title, it’s a sign that there’s something amiss, a lack of confidence in the story (and the audience’s intelligence) that’s in itself telling. But that’s what happens in William Maher’s “Sleepwalking,” written by Zac Stanford (“The Chumscrubber”). Though pictures focusing on the conditions of marginalized members of society are always welcome at a time when Hollywood avoids the subject, even a good cast operating at a high level isn’t enough to save this stylistically strange, sluggish and ultimately unsatisfying domestic drama.

Charlize Theron, who was also one of six producers, plays Joleen, a white-trash single mother who loses her digs when her boyfriend’s busted for growing weed. Along with her teenaged daughter Tara (AnnaSophia Robb), she turns up at the dumpy apartment of James (Nick Stahl), her doormat of a brother, who’s improbably nicknamed Speedy by his unhappy construction boss. But Joleen soon decamps alone, leaving Tara behind; and though James briefly tries to prove a suitable guardian for the girl, he’s soon lost both apartment and job and moves into the basement of his boozy, skirt-chasing chum Randall (Woody Harrelson) while Tara’s sent to a state-run home.

On her birthday, though, James spirits Tara surreptitiously from the place and, pretending to be father and daughter to evade the authorities, they ride the road until, running short of funds, he decides they should visit his father Reedy (Dennis Hopper), a gloomy, tyrannical cattle rancher. It’s when Reedy abuses Tara the way he did Joleen years before that James rouses himself from his customary lethargy—he speaks of himself as being awakened from his sleepwalking—to intervene, with violent result, though there is a happy ending with mother and daughter reunited.

The narrative trajectory here is a trifle peculiar, but what really sends “Sleepwalking” off the rails are the wild shifts in tone from act to act. The first third of the picture is somber kitchen-sink melodrama, lightened only by Harrelson’s lunkhead humor. In the “road movie” middle, the mood turns almost lighthearted, with one sequence in particular—a “Lolita”-like episode in which Tara lolls poolside at a motel ogled by two younger boys—that takes on a positively phantasmagoric feel. Then the long sojourn at Reedy’s ranch takes a surrealistic twist, with expressionist visuals that move halfway toward the look of “The Night of the Hunter.” And it closes with a coda that returns us to the original gritty atmosphere, but with a hopeful touch.

That’s an ambitious stylistic agenda, and frankly Maher doesn’t have the skill to pull it off. As a result the picture doesn’t hang together; each individual section exhibits some points of interest, but taken together they refuse to cohere. Happily the failing is redeemed to some extent by the performances. Stahl and Robb are particularly good, his lumpy desire to please playing off well against her sharp frustration. And while Hopper and Harrelson indulge in considerable overstatement, though in very different ways (Hopper simmering with malevolent rage, Harrelson bubbling with dopey energy), they’re both enjoyable to watch. Theron, by contrast, is surprisingly bland in what is, after all, a pretty thankless role.

On the technical side credit is due cinematographer Juan Ruiz-Anchia, who differentiates the various segments expertly, and production designer Paki Smith, whose work in the gray-drenched solitude of the ranch section is especially striking. And Christopher Young contributes a suitably mournful score.

But this is a film of bits and pieces that never come together into a satisfactory whole. The meandering “Sleepwalking” is an interesting failure.